Wrox Programmer Forums
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2004, 09:00 AM
Authorized User
 
Join Date: Oct 2003
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default php question

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?

 
Old January 28th, 2004, 02:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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/





Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Installation question EnderX PHP How-To 0 November 9th, 2006 09:47 AM
PHP RPM Question EnderX PHP How-To 0 November 8th, 2006 05:16 PM
PHP *hosting* question cutesneakers PHP How-To 3 January 5th, 2005 08:35 PM
PHP Form Question IP076 PHP How-To 1 December 8th, 2004 05:12 AM
PHP real question jimmychuck BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 September 14th, 2004 11:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.