html - php option value link -
i created dropdown menu , when click on option on category in drop down bar, can link product page, failed linked them, know problems in code?
enter code here
$link=mysql_connect("localhost","root","")or die("can't connect..."); mysql_select_db("fyp",$link) or die("can't connect database..."); $query="select * category "; $res=mysql_query($query,$link); while($row=mysql_fetch_assoc($res)) { echo "<option value='product.php category=".$roww['$cat_id']."'>".$row['cat_nm'];///here problem $qq = "select * subcat parent_id=".$row['cat_id']; $ress = mysql_query($qq,$link) or die("wrong delete subcat query.."); while($roww = mysql_fetch_assoc($ress)) { echo "<option value='".$roww['subcat_id']."'> ---> ".$roww['subcat_nm'];//here problems } } mysql_close($link); ?>
try , use mysqli instead of mysql, mysql deprecated(suggestion)
$link=mysqli_connect("localhost","root","")or die("can't connect..."); mysqli_select_db($link,"fyp") or die("can't connect database..."); $query="select * category"; <select onselect='gourl(this.value)' id="cval" name="cval"> $res=mysqli_query($link,$query); while($row=mysqli_fetch_assoc($res)) { echo "<option value='".$row['cat_id']."'>".$row['maincatname']."</option>"; $qq = "select * subcat parent_id=".$row['cat_id']; $ress = mysqli_query($link,$qq) or die("wrong delete subcat query..".mysqli_error($link)); while($roww = mysql_fetch_assoc($ress)) { echo "----><option value='".$roww['subcat']."'>".$roww['subcatname']."</option>"; } } </select> mysqli_close($link); ?> <script> function gourl(catgry) { window.location.href='product.php?category='+catgry; } </script>
Comments
Post a Comment