Dear all
Using this code a combo box can be dynamically populated using php code.
-------------------------
<?php
if($con=mysql_connect("localhost","root",""))
{
//echo"connected";
}
else
{
//echo"not connected";
}
mysql_select_db("fjc");
//start combo box code.
function showcombobox($tablename,$valuefield,$showfield)
{
$sql="select $valuefield,$showfield from $tablename";
echo $sql;
$data=mysql_query($sql);
$retvalue='';
while($row=mysql_fetch_array($data))
{
$retvalue=$retvalue."<option value='".$row[$valuefield]."'>".$row[$showfield]."</option>";
}
return $retvalue;
}
//start combo box code.
?>
-------------------------------
Using this code a combo box can be dynamically populated using php code.
-------------------------
<?php
if($con=mysql_connect("localhost","root",""))
{
//echo"connected";
}
else
{
//echo"not connected";
}
mysql_select_db("fjc");
//start combo box code.
function showcombobox($tablename,$valuefield,$showfield)
{
$sql="select $valuefield,$showfield from $tablename";
echo $sql;
$data=mysql_query($sql);
$retvalue='';
while($row=mysql_fetch_array($data))
{
$retvalue=$retvalue."<option value='".$row[$valuefield]."'>".$row[$showfield]."</option>";
}
return $retvalue;
}
//start combo box code.
?>
-------------------------------