hello .. m trying to get/fetch the database value into dropdown box as a selected value in the dropdown box using PHP script and mysql - phpmyadmin database ..
but m having problems in it .. here is my script which i m using ..
try.php
<body>
<?php
$conn = mysql_connect("localhost","root","") or die("could not connect to localhost");
mysql_select_db("test") or die("could not connect to database");
$qry = "select * from table1 where id=1";
$result = mysql_query($qry) or die(mysql_error());
?>
<select name="date">
<?php
while($rows = mysql_fetch_array($result))
{
$myDate=$rows['date'];
?>
Date :
<?php
for ($date=1;$date<=31;$date++)
{
if ($myDate==$date)
{
$s="selected='selected'";
}
else
{
$s="";
}
?>
<option value="<?php echo $date; ?>" <?php echo $s ;?>><?php echo $date; ?></option>
<?php
}
?>
<?php
}
?>
</select>
</body>
m getting the values from 1 TO 31 in my drodown box
BUT NOT ABLE TO GET THE "SELECTED" VALUE WHICH IS 25 IN MY DATABASE
..please somebody tell me .. where is wrong m here in this script . .