本文介绍了PHP从mySQL到依赖于表中组的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 我正在尝试使用从数据库中标记为productpr [number]和qty [number]的项目填充每个下拉列表,然而它不断为每个结果创建一个新的下拉菜单,可能是非常简单的东西,但是会很感激帮助。 问候, 詹姆斯 数据看起来像这样... ID | PIDx | QTYx |价格| jPrice | CartDescription | ViewDescription 1 | productpr1 | qty1 | 10 | 10 | 1 | 1 2 | productpr1 | qty1 | 10 | 10 | 1a | 1a 3 | productpr2 | qty2 | 11 | 11 | 2 | 2 4 | productpr2 | qty2 | 11 | 11 | 2a | 2a 创建这样的html; Hi Guys,I'm trying to populate each drop down with items that are labled as productpr[number] and qty[number] from a database, however it keeps creating a new drop down for each result, probably something really simple, but would appreciate the help.Regards,Jamesdata look like this...ID | PIDx | QTYx | Price | jPrice | CartDescription | ViewDescription1 |productpr1 |qty1 |10 |10 |1 |12 |productpr1 |qty1 |10 |10 |1a |1a3 |productpr2 |qty2 |11 |11 |2 | 24 |productpr2 |qty2 |11 |11 |2a |2acreating a html like this;<b>Choose an Operating System</b><input type="hidden" value="1" name="qty1"><select name="productpr1"><option>---</option><option id="10" value="1:10">1</option></select><br><br> <?$objConnect = mysql_connect("localhost","username","password") or die(mysql_error());$objDB = mysql_select_db("database");$strSQL = "SELECT * FROM puterz";$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");?><br><br><br><br><br><br><br><h1>Configure your own AMD Based PC and let us build it for you.</h1> <form action="http://wwx.aitsafe.com/cf/addmulti.cfm" method="post"> <input name="userid" type="hidden" value="1234567"><?while($objResult = mysql_fetch_array($objQuery)){?><?if($objResult["PIDx"] == "productpr1" && $objResult["QTYx"] == "qty1"){?>Choose an Operating System<input type="hidden" value="1" name="<?=$objResult["QTYx"];?>"><select name="<?=$objResult["PIDx"];?>"><option>---</option><option id="<?=$objResult["jPrice"];?>" value="<?=$objResult["CartDescription"];?>:<?=$objResult["Price"];?>"><?=$objResult["ViewDescription"];?></option></select><br><br><?}if($objResult["PIDx"] == "productpr2" && $objResult["QTYx"] == "qty2"){?>Choose a Case<input type="hidden" value="1" name="<?=$objResult["QTYx"];?>"><select name="<?=$objResult["PIDx"];?>"><option>---</option><option id="<?=$objResult["jPrice"];?>" value="<?=$objResult["CartDescription"];?>:<?=$objResult["Price"];?>"><?=$objResult["ViewDescription"];?></option></select><?}}?><!-- Send Button --><input name="return" type="hidden" value="#"><input type="submit" value="Buy Now!"> </form><?mysql_close($objConnect);?> 推荐答案 这篇关于PHP从mySQL到依赖于表中组的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-19 04:04