|
|
|
/*
Usage: void makeDrop (string,string,string,string)
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:
....<html>...
<select name="accountid">
<?
makeDrop($database,"accounts","accountid","accountname");
?>
</select>....</html>
Usage: void makeDropLong(string,string,string,string,string)
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:
<select name="eid">
<?
makeDropLong($database,"employees","eid","fname","lname");
?>
</select>
*/
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++;
}
}
}
|
|
| html split bar used to split in multiple pages a database result Categories : HTML and PHP, Databases, MySQL, PHP | | | Automatically printing the contents of an sql table in MySQL. Categories : MySQL, PHP, HTML and PHP, Databases | | | Dynamically generated pop-ups (Select items) Categories : PHP, HTML and PHP, MySQL, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Functions for loading images into a MySQL database and displaying them. Categories : Graphics, HTML and PHP, MySQL, PHP, Databases | | | Pull Down Surfing - Surf on Change Categories : Java Script, MySQL, HTML and PHP, PHP, Databases | | | Creating thumbnails from MySQL Blobs online Categories : PHP, MySQL, Graphics, HTML and PHP, Databases | | | How can i Preload a 'SELECT MULTIPLE'? Categories : HTML and PHP, PHP, MySQL, Databases | | | Record Set Paging with PHP (RSP) Categories : PHP, MySQL, Navigation, Databases, HTML and PHP | | | dynamic table columns Categories : PHP, HTML and PHP, Arrays, Databases, MySQL | | | phpEasySQL - Easily connect to your MySQL database with just 1 php file and 3 easy steps! Categories : Databases, PHP, MySQL, General SQL | | | Editing the virtusertable and sendmail.cw via PHP3.0 and Mysql Categories : MySQL, HTML and PHP, PHP, Databases | |
|
|
|