Page 1 of 1

Populate listbox from a table PLEASE HELP

Posted: Wed Mar 03, 2004 10:00 am
by Rmias
Hi,

I created databases for a book store and I would like to create an Order process page that will contain customer name and book name and the other details. I have the following tables

customer - {cust_id, name and etc...}
book - {book_id, title and etc .......}
order {order_id order_date and etc........}
orderBook - {order_id, book_id, cust_id and etc..}

what i would like to do is in the order page I would like to populate customer id and name to the listbox from customer table and pass only the cust_id to process_order php, and the same with books.

Is there an easy way of implementing the code? Please help me as I am stuck on this problem for more than a week

Thank you

Posted: Wed Mar 03, 2004 10:43 am
by qads
you just need the drop down menu?

if so...

<select name="cust_id" size="1">

Code: Select all

<?php
$query = mysql_query("select ID, name from custmers order by name ASC");
while($row= mysql_fetch_array($query))
{
echo '<option value="'.$row['ID'].'">'.$row['name'].'</option>';
}
?>
</select>

Posted: Thu Mar 04, 2004 8:20 am
by Rmias
thank you quads i will try it.

again thanks for your help