Display data in drop down list

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
danielbala
Forum Newbie
Posts: 9
Joined: Tue Jan 24, 2012 4:27 pm

Display data in drop down list

Post by danielbala »

Hi..

Im new to php..Please help me

I created 2 tables and 2 forms
ringodetails-Table1
servicedetails-Table2

In service.php form i have to display the customer names in a drop down list from the ringodetails table

I got customer names in the ringodetails table

How to implement this....

Thx in advance
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Display data in drop down list

Post by social_experiment »

You need to select all the customer names from the ringodetails table. Then place the results in an array from where you display them.

Code: Select all

<?php 
 $qry =  "SELECT `customer_name` FROM `ringodetails`"; 
 $sql = mysql_query($qry);

 echo '<select name="aName">';
 while ($ary = mysql_fetch_array($sql)) {
    echo '<option>' . htmlentities($ary['customer_name'], ENT_QUOTES) . '</option>';
 }
 echo '</select>';
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply