php实现三级级联下拉框(2)

<?php header('Content-Type:text/html;charset=GB2312'); $conn = mysql_connect('localhost', 'root', '') or die('Could not connect: ' . mysql_error()); mysql_select_db('fitment', $conn) or die ('Can\'t use database : ' . mysql_error()); mysql_query("set names 'gb2312'"); //如果传递过来q if($_GET["q"]){ $strs = "SELECT * FROM fitment_sort WHERE supid=' ".$_GET["q"]."' "; //echo $str; $results = mysql_query($strs) or die("Invalid query: " . mysql_error()); if($results) while ($arrs = mysql_fetch_array($results)){ $strings .= $arrs["id"]."|".$arrs["name"].","; } echo substr($strings,0,strlen($strings)-1); } //如果传递过来q2 if($_GET["q2"]){ $str = "SELECT * FROM fitment_sort WHERE supid= '".$_GET["q2"]."'"; //echo $str; $result = mysql_query($str) or die("Invalid query: " . mysql_error()); if($result) while ($arr = mysql_fetch_array($result)){ $string .= $arr["id"]."|".$arr["name"].","; } echo substr($string,0,strlen($string)-1); } mysql_close($conn); ?>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/381340f0395ae7f3e376d79286822e09.html