Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create drop-down box its dat 1

Status
Not open for further replies.

hisham

IS-IT--Management
Nov 6, 2000
194
How to create drop-down box its data stored in a mysql table? i.e. I have a table named countries, contain a field : countriesname, and I want to display the content of this field in the drop-down box,.

Thanks in advance.
 
define database connection here
<?
//define the sql statement
$strQry = &quot;SELECT countriesname, countryID from countries&quot;;
//I am assuming that you have a field called countryID
//which is the unique identifier
//send the query to mysql
$objCountries = mysql_query($strQry);
//count the number of rows returned
$CountryCount = mysql_num_rows($objCountries);
?>

<select name=&quot;CountryID&quot;>
<?while ($CountryRow = mysql_fetch_array($objCountries)) {?>
<option value=&quot;<?=$CountryRow[&quot;CountryID&quot;]?>&quot;><?= $CountryRow[&quot;countriesname&quot;]?></option>
<?}?>
</select>

hope this helps
 
Thank you very much arperry for your answer,
This is what I was looking for.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top