Click here to Skip to main content

J3ffers asked:

Open original thread
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,
James
 

data look like this...
 
ID | PIDx | QTYx | Price | 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
 
creating 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);
?>
Tags: HTML, PHP, MySQL

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100