Hi All,
I am using this code to populate a drop down list from mysql database.
I need to pass id and name through this code.but the problem is the value is lost when the page gets refreshed.and it works fine if i pass only name through it.
my code is as follows:

<?PHP
$query=mysql_query("SELECT * FROM client_master WHERE client_status=1");?>
<select name='name' onChange='javascript:form_submit();' style='width:80px'>
<option value="">-SELECT-</option>
<?php
while($row=mysql_fetch_array($query))
{
$name=$row['client_name'];
?>
<option value="<?php echo $row['client_id'] ?>" <?php echo($row['client_name']==$_POST['name'])?'selected':''?>>
<?php echo $row[client_name];?>
</option>
<?php
}
?>
</select>
<script language="javascript">
function form_submit(){
    document.gr.submit();
}
</script>

If you don't want the value to be lost when refresh maybe you can use session variable.

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.