phpscipt for customers information from database in dropdown

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
david23
Forum Newbie
Posts: 1
Joined: Thu Aug 03, 2006 11:23 am

phpscipt for customers information from database in dropdown

Post by david23 »

Hi Guys,

I have an application script in php and in one page it is having customer search option in text box.If i want to search for one customer i need to enter the customer name in text box and it will display the details and other stuff about the customer from database.Now my client want dropdown box with all the customer names existing in database so that it will be easy for them to view all the customers.

Database :- mysql
Language :- php

Variables defined

$customer = $_GET['customer'];

echo "Customer: $customer <BR>\n";


How to implement this and i really appriciate your help.

Best Regards
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Something like
UNTESTED:

Code: Select all

print('  <select name="select" id="select">' );

$query = mysql_query("SELECT customer_name FROM databasetable ORDER BY customer_name");
$customers = mysqk_fetch_array();
foreach($customers['customer_name'] as $name){
    print("<option>$name</option>");
}
print('</select>');
And then what ever you want to do with the list...

feyd | *grumble* tags.
Post Reply