Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add new fields/rows [button] to a webpage

    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.

  • #2
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    <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:
    Code:
    $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?

  • #3
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the reply.....

    Will try it out asap...

    ~Aniket.

  • #4
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ----edited-----
    Last edited by aniket_dj; 03-16-2007 at 03:22 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •