Hi, For a dropdown , I display from one table, While Editing How to show the selected value in that dropdown.

<select name="dropdown">
<option value="">--Select--</option>
<?php
$a=mysql_query("Select * from student whre status='0'")or die(mysql_error());
$b=mysql_num_rows($a);
if($b >0)
{
while($row=mysql_fetch_array($a))
{
?>
<option value="<?php echo $row['st_id']?>"><?php echo $row['name'] ?></option>
<?php } } ?>
</select>

This is my dynamic select box code for insert , I don`t know how to edit? Can any one tell me?
<select name="dropdown">
<option value="">--Select--</option>
<?php
$a=mysql_query("Select * from student whre status='0'")or die(mysql_error());
$b=mysql_num_rows($a);
if($b >0)
{
while($row=mysql_fetch_array($a))
{
$selected = ( $row['st_id']=="id_for_compare" ? ' selected' : '' );
echo '
<option value="'.$row['st_id'].'"'.$selected.'>'.$row['name'].'</option>';
} } ?>
</select>

or use $row['name'] if you want compare rowname

Please first of all mysql database connection layer is deprecated, so try to use mysqli or PDO for database connections.

And, I don't actually get what you are trying to say. Can you please ellaborate your question further.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.