Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:03:32+00:00 2026-06-12T04:03:32+00:00

I have a table being generated from PostgreSQL through PHP. The user needs to

  • 0

I have a table being generated from PostgreSQL through PHP.

The user needs to have the option of deleting the row or updating it.

So I have successfully implemented a delete button utilizing hidden elements to pass the key information for the deletion to my delete.php

Now I am trying to add an update button which will send the php to my update.php rather than my delete.php.

However, when I open my form I tell it where to send the data upon submission.

My question then is, is there a way that I can have both buttons available and depending on which button is pressed the form posts the data to the appropriate php- delete.php vs update.php? Perhaps some attribute of input buttons I cannot think of that can direct where to POST rather than having it as a form attribute?

Here is an example of what I have:

 echo '<form action="delete.php" method="POST">';
        echo '<tr>';
        echo '<td class="even">' . $row['id'] . '</td>';
        echo '<td class="odd">' . $row['name'] . '</td>';
        echo '<td class="even">' . $row['countrycode'] . '</td>';
        echo '<td class="odd">' . $row['district'] . '</td>';
        echo '<td class="even">' . $row['population'] . '</td>';
        echo '<input type="hidden" name="todelete" value="'.$row['countrycode'].'"  />';
        echo '<input type="hidden" name="cityname" value='.$row['name'].'" />';
        echo '<input type="hidden" name="tablename" value="'.$_POST["search-type"].'"  />';
        echo '<td> <input class="odd" type="submit" name="updateBtn" value="Update?"  /></td>';
        echo '<td> <input class="even" type="submit" name="deleteBtn" value="Delete?" /></td>';
        echo '</tr>';
        echo '</form>';

This is generated for each row of the table so each of the forms is unique and only that data is sent.

Let me know if you have any ideas how I can implement the two buttons!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:03:34+00:00Added an answer on June 12, 2026 at 4:03 am

    Simplest method is to have a SINGLE script as your action, then have a basic

    <?php
    
    if (isset($_POST['deleteBtn'])) {
       ... do delete stuff
    } else if (isset($_POST['updateBtn'])) {
       ... update stuff here ...
    }
    

    Otherwise you’re stuck with some javascript to dynamically change the action target.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html table containing values that are being generated from javascript. How
I have a table being generated from an array of NSManagedObjects. This works fine
I have a table which is being dynamically populated, each row contains two textfields
I have a table which is being dynamically populated from MySQL. The table has
I have PHP radio buttons being generated by the following code: while($a_row = mysql_fetch_array($answers_result))
I have a table being generated in an ASP.net web app. The table has
I have a table with the only relevant column being completionDate, a number of
I have a table of data that is being sorted alphabetically, and it's a
I currently have a table with an id column that is being autoincremented and
So I have a local SQLite table breadcrumbs being created on the Android device.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.