Creating Dynamic Select Box Using PHP

Posted on Posted in PHP

function drop_down($table,$label,$value)
{
/*
@table : Table name from which drop down will genrate
@label : Label name wich display on drop down in user level
@value : Value wich will associate on dropdown on value attribute
*/

$qs=”select * from $table”;
$data=mysql_query($qs);
$result=””;
while($row=mysql_fetch_array($data))
{
$result.=”<option value='”.$row[$value].”‘>”.$row[$label].”</option>”;
}
return ($result);
}

Leave a Reply

Your email address will not be published. Required fields are marked *