This function will make a drop down list from the results of a mysql database
quey.
It takes the database name, the table, the id for that table and the name it
goes by.
For Example: if the table was Accounts, and the ID was account, the you wanted
to show accountname you would say:
This function will make a drop down list from the results of a mysql database
quey.
It takes the database name, the table, the id for that table and the TWO names
it goes by.
For Example: if the table was Employees, and the ID was eid, the you wanted
to show the first name and the last name of the employee you would say:
*/
function makeDrop ($database,$table,$id,$idname)
{
$results=mysql($database,"select $id,$idname from $table order by $table.
$idname asc");
echo mysql_error();
if (mysql_Numrows($results)>0)
{
$numrows=mysql_NumRows($results);
$x=0;
while ($x<$numrows){
$theId=mysql_result($results,$x,$id);
$theName=mysql_result($results,$x,$idname);
echo "<option value=\"$theId\">$theName</option>\n";
$x++;
}
}
}
function makeDropLong ($database,$table,$id,$idname1,$idname2)
{
$results=mysql($database,"select $id,$idname1,$idname2 from $table order by
$idname1 asc");
if (mysql_Numrows($results)>0)
{
$numrows=mysql_NumRows($results);
$x=0;
while ($x<$numrows){
$theId=mysql_result($results,$x,$id);
$theName1=mysql_result($results,$x,$idname1);
$theName2=mysql_result($results,$x,$idname2);
echo "<option value=\"$theId\">$theName1 $theName2</option>\n";
$x++;
}
}
}