|
|
|
/*
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++;
}
}
}
|
|
| Functions for loading images into a MySQL database and displaying them. Categories : Graphics, HTML and PHP, MySQL, PHP, Databases | | | dynamic table columns Categories : PHP, HTML and PHP, Arrays, Databases, MySQL | | | Pull Down Surfing - Surf on Change Categories : Java Script, MySQL, HTML and PHP, PHP, Databases | | | Dynamically generated pop-ups (Select items) Categories : PHP, HTML and PHP, MySQL, Databases | | | Complex paging with no resultset limit Categories : PHP, MySQL, Databases, Output Control, HTML and PHP | | | Sql Builder Categories : PHP, HTML and PHP, Databases, General SQL, Form Processing | | | phpFormGenerator for Dynamic Form Generation from MySQL Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP | | | 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 | | | Required form fields that pull from MySQL database Categories : PHP, HTML and PHP, Databases, MySQL | | | phpEasySQL - Easily connect to your MySQL database with just 1 php file and 3 easy steps! Categories : Databases, PHP, MySQL, General SQL | | | mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases | | | Creating thumbnails from MySQL Blobs online Categories : PHP, MySQL, Graphics, HTML and PHP, Databases | | | Record Set Paging with PHP (RSP) Categories : PHP, MySQL, Navigation, Databases, HTML and PHP | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | |
|
|