How to Display Data from Database to selectbox

It is very easy. At first you have to insert some data to your database suppose its database name is naogaon and table name is member and there is colum name by number then.. write the following code and save you as your like.. ok done check it.

//    …………………Selectbox.php…………………….\\

$con = mysql_connect(“localhost”,””,””);
if (!$con)
die(‘Could not connect: ‘ . mysql_error());
mysql_select_db(“naogaon”, $con);
$query = “SELECT number FROM member order by number “;

$result = mysql_query($query) or die(“Couldnt execute query.”);

echo ‘<select name=”number” id=”number”>’;
while($row = mysql_fetch_array($result))
$val = $row[‘number’];
echo “<option value=$val>$val</option>”;
echo ‘</select>’;



  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: