Page 1 of 1

Display data in drop down list

Posted: Tue Feb 07, 2012 5:20 am
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

Re: Display data in drop down list

Posted: Tue Feb 07, 2012 5:52 am
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>';
?>