|
Subject:
|
php question
|
|
Posted By:
|
hosefo81
|
Post Date:
|
1/28/2004 8:00:55 AM
|
i have two text box. a add button and a table. after each time a user enter a product id and quantity to the textbox, and then clicked the add button, the entered data and the previously entered data will be displayed on the table. My question is : is it possible to displayed all the entered data each time after the button is clicked?
|
|
Reply By:
|
nikolai
|
Reply Date:
|
1/28/2004 1:02:32 PM
|
Yes, it's very easy. If you're storing all the user input in a database, just select all the input that the user submitted from the database and generate your HTML table from that.
In pseudo-php:
<?php
db_connect(...);
// Insert any new rows into the database. if (isset($_POST['new_entry'])) { db_query("insert new entry into database"); }
// Get all the rows from the database and output them in a table. $result = db_query("select all rows from database");
echo "<table>\n";
// each database row is output in its own table row. while ($row = db_fetch_array($result)) { echo " <tr>\n"; echo " <td>{$row['col1']}</td>\n"; echo " <td>{$row['col2']}</td>\n"; echo " ...\n"; echo " </tr>\n"; } echo "</table>\n";
// output the form to create a new row. echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">\n"; echo " <input ... />\n"; echo "</form>
?>
Take care,
Nik http://www.bigaction.org/
|