...

View Full Version : Add new fields/rows [button] to a webpage



aniket_dj
03-16-2007, 01:21 AM
Hi,

I am new to this forum as i am new to PHP in general. So a general hello to all folks in here.

Basically what I am doing is getting tuples from database (MySQL) and putting them in a table using PHP+HTML. After the whole table is displayed, I want the user to add another row to the database by having an add key.

The add key, adds a new row (with a the same number of fields as the previous tuple). After hitting the submit button, the changes should be reflected back into the database.

As far as I know (for a novice to web programming in general), I can have a single submit button which submits the form contents to the server. As this is an update webpage operation, rather than a submit op, how do I go about it?

Thanks.

~Aniket.

cshireman
03-16-2007, 01:29 AM
There are several ways to go about something like this. You can actually have more than one submit button per form. Give all the buttons the same name, but have differnet values for each.

ex:

<input type="submit" name="Command" value="Save"><br>
<input type="submit" name="Command" value="AddRow"><br>
<!--etc-->

In your PHP, look for the value of code like this:

$command = $_GET['Command'];
if("Save" == $command)
{
//Save something
}
elseif("AddRow" == $command)
{
//Add a Row
}
//etc...

Depending on which command you just processed you can display different buttons. Does this help?

aniket_dj
03-16-2007, 01:40 AM
thanks for the reply.....

Will try it out asap...

~Aniket.

aniket_dj
03-16-2007, 02:20 AM
----edited-----



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum