|
|
|
This code snippet will allow you to generate pop-up items by querying the
specific table in a database. This is particularly useful if you have data
that grows (for example, if your clients can add information to your tables,
like states they ship to, or job categories, etc.) This way, your .php3
files or HTML won't have to be updated.
<?php
//.
//.
//.
function show_options($db, $tableName)
{
$result = db_query ($db, "SELECT * FROM $tableName");
while (list($id, $name) = db_fetch_row($result))
{
echo "<option value=$id>$name</option>\n";
}
}
//.
//.
//.
?>
<body>
<select name="State">
<?php show_options($dbid, "TABLENAME"); ?>
</select>
</body>
|
|
| 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 | | | 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 | | | Editing the virtusertable and sendmail.cw via PHP3.0 and Mysql Categories : MySQL, HTML and PHP, PHP, Databases | | | This function will populate the options in a drop down HTML select list
in a form from a database query.
Categories : MySQL, General SQL, PHP, HTML and PHP, Databases | | | Paginating the mySQL data Categories : PHP, Algorithms, Databases, MySQL, HTML and PHP | | | PHP and MySQL scripting for Muyltiple CheckBoxes Categories : HTML and PHP, MySQL, Databases, PHP | |
| | | | David Keaveny wrote :383
I hope I don`t need to point this out, but the line that
reads
while (list($id, $name) = $db_fetch_row($result))
should of course read
while (list($id, $name) == $db_fetch_row($result))
since you`re testing for equivalence. Guess who got
caught out by that one :-)
| |
|
|
|