|
|
|
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>
|
|
| 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 | | | Functions for loading images into a MySQL database and displaying them. Categories : Graphics, HTML and PHP, MySQL, PHP, Databases | | | Complex paging with no resultset limit Categories : PHP, MySQL, Databases, Output Control, HTML and PHP | | | phpFormGenerator for Dynamic Form Generation from MySQL Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP | | | 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 | | | 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 | | | Function to do live population of HTML's <Select> tag from a Table Categories : PHP, MySQL, HTML and PHP, Databases | | | Storing / Retrieving pictures from database This can be used for banner / ads exchange. very useful for people developing big portal with ads in the site........ Categories : PHP, MySQL, Databases, HTML and PHP | | | 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 | | | Database resultset navigation Categories : PHP, HTML and PHP, Databases, MySQL, Navigation | | | Editing the virtusertable and sendmail.cw via PHP3.0 and Mysql Categories : MySQL, HTML and PHP, PHP, Databases | |
| | | | 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 :-)
| |
|
|