Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FILL COMBO WITH DATA FROM A RECORDSET

Status
Not open for further replies.

lechuz

Programmer
Jan 8, 2003
26
0
0
MX
Hi!

I have an stored procedure that returns to my PHP page a recorset with data.

Does anyone have a sample code in how can I fill my combo box with the data in the recordset? I'm a begginer in PHP and I can't find on web a sample code for this...

I will appreciate a lot your help
 
Hi,

I'm not sure if this is the conventional way to do it, but it works for all my pages. Here, I am filling a select box full of categories, and asking the user to select one to show all the items with that Category_ID. The select box will fill with all the Category_Name's and have the value of the Category_ID. $row_getcategories is the data set that I have brought back from my db:

<select name=&quot;Category_ID&quot;>

<?php do { ?>

<option value=&quot;<?php echo $row_getcategories 'Category_ID']?>&quot;>
<?php echo $row_getcategories['Category_Name']?></option>

<?php } while ($row_getcategories = mysql_fetch_assoc($getcategories));

$rows = mysql_num_rows($getcategories);
if($rows > 0) {
mysql_data_seek($getcategories, 0);
$row_getcategories = mysql_fetch_assoc($getcategories);
}
?>

Hope this helps

sipps
 
Your code it's helpfull, but, you are working with mysql, I'll try to find the same commands for SQL server in wich I am working.

Thanks a lot.
 
Sorry if it wasn't any use for you!

sipps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top