gpt4 book ai didi

php选项值链接

转载 作者:行者123 更新时间:2023-11-29 11:56:54 25 4
gpt4 key购买 nike

我创建了一个下拉菜单,当单击下拉栏中类别的选项时,它可以链接到我的产品页面,但我无法链接它们,有人知道我的代码有什么问题吗?

在此处输入代码

$link=mysql_connect("localhost","root","")or die("Can't Connect...");
mysql_select_db("fyp",$link) or die("Can't Connect to Database...");
$query="select * from 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 is the problem
$qq = "select * from subcat where 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 is the problems
}

}

mysql_close($link);

?>

enter image description here

最佳答案

尝试这个并使用 mysqli 而不是 mysql,mysql 已弃用(建议)

    $link=mysqli_connect("localhost","root","")or die("Can't Connect...");
mysqli_select_db($link,"fyp") or die("Can't Connect to Database...");
$query="select * from 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 * from subcat where 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>

关于php选项值链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33051181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com