Populate listbox from a table PLEASE HELP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rmias
Forum Newbie
Posts: 24
Joined: Wed Nov 26, 2003 11:02 am

Populate listbox from a table PLEASE HELP

Post 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
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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>
Rmias
Forum Newbie
Posts: 24
Joined: Wed Nov 26, 2003 11:02 am

Post by Rmias »

thank you quads i will try it.

again thanks for your help
Post Reply