Click here to Skip to main content
11,929,675 members (56,587 online)
Rate this:
Please Sign up or sign in to vote.
See more: HTML PHP MySQL
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.


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 id="10" value="1:10">1</option>

$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."]");
Posted 28-Jan-13 6:21am
J3ffers 29-Jan-13 12:20pm
Anyone else able to help?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You have your DB iterator

while($objResult = mysql_fetch_array($objQuery))

and inside this iterator you generate select box markup

<select name="<?=$objResult[" pidx="];?>"></select>

According to if criteria, you will create one select per each row.

Consider refactoring the code, by moving select tag generation outside of the items loop.
J3ffers 28-Jan-13 11:51am
I've tried this and still get a similar result?
Vyacheslav Voronenko 28-Jan-13 11:52am
Where is updated code?
Vyacheslav Voronenko 28-Jan-13 12:01pm
I think, some markup was filtered out during commenting
J3ffers 28-Jan-13 12:13pm
Completely stuck on this one :(, I've tried it every way possible.. (I think)

Is there another way?
Vyacheslav Voronenko 28-Jan-13 14:05pm
I think it is wrong to mix different entities (case, operating system) in one table/recordset. Better to split them into two different recordsets.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Managed to fix this myself some time ago, just clearing my old questions out.. Thanks to all that made suggestions...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 9 Jul 2013
Copyright © CodeProject, 1999-2015
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