Saturday, 22 February 2020

Dynamic Combobox

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.

?>
-------------------------------

2 comments:

  1. awesome! Finally, someone described it concretely and without duplicating the same definitions as everywhere. I wish you a lot of enthusiasm and continue what you do, and you will certainly start earning on it, just a little better position yourself in google because first of all there are some shit php courses that do not bring anything new to the subject, not what yours. Bluehost hosting plans

    ReplyDelete