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 9132113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:15:25+00:00 2026-06-17T08:15:25+00:00

I have a simple table with a accept and decline button in each row.

  • 0

I have a simple table with a accept and decline button in each row. If you press accept i need it to add 10 to a MYSQL column based on a unique reference. If decline add 20 with the same reference (one per row)
I have the following code to create the table and buttons.(connection etc taken out)

<form Action="leaveupdate.php?" method="POST" >
$query= "
SELECT t0.*, t1.id_user as t1user, t1.name as t1name
FROM $loc t0
LEFT JOIN login1st t1 ON t0.User_id = t1.id_user
WHERE t0.status >=10 and status <20 ORDER BY Date_Input ASC
";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$fieldCount = mysql_num_fields($result);
echo "<TABLE border='1' cellspacing='0' cellpadding='15' id='sort_table' width='490px'>    <thead><TR bgcolor=#ffffff>";
?>
<legend>Research results!</legend>
<table border="1" width="75%" cellpadding="2" cellspacing="0">
<tr>
        <TD align="center">Requestor</TD>
        <TD align="center">Leave type</TD>
        <TD align="center">Date requested</TD>
        <TD align="center">Date Requested</TD>
        <TD align="center">ACCEPT</TD>
        <TD align="center">DECLINE</TD>
</tr>
        <?
echo "</TR></thead><tbody>";
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo'<td align=middle>' . $row["t1name"]                      . '</td>' ; // Requestor
echo'<td align=middle>' . $res                       . '</td>' ; // Status
echo'<td align=middle>' . date("l", $row["date_effected"]) . "<BR>". date("j-M-Y",   $row["date_effected"])     . '</td>' ; // Day off
echo'<td align=middle>' . date("d-m-y @ H:i", $row["Date_Input"])             . '</td>'   ; //Date Requested
echo'</td><td><input type="submit" name="edit" value="10" class="buttons2">';//Add 10
echo'</td><td><input type="submit" name="edit" value="20" class="buttons3">';//Add 20
echo'<td alighn=middle>'.$row["Unique_id"].'</td>';Just for testing not needed will be removed from the table
echo '</tr>';
}
echo "</tbody></TABLE>";
?>
</table>
</body>
</html>

This is posted ( i use get to see what happens but will be changed) to this page

<?php
$loc = $fgmembersite->UserLocation();
$conn = mysql_connect("****","******","Pword");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db("****",$conn) or die ("Could not open database");
if(!isset($_POST['edit']))
{
//add die here
}

$IU            =    ($_POST['Unique_id']);
$change            =    ($_POST['edit']);
$sql_query_update = "update $loc set status = status+$change where unique_id = IU";
mysql_query( $sql_query_update );
echo $sql_query_update;//only for testing will be removed
mysql_Close()
?>

as you can see i was hoping to have two variables IU and change, but can’t figure it out. Probably easy but if some could assist it would be helpful.I have been reading the web and seen reference to AJAX but have never used or looked into this.
Thanks JD

  • 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-17T08:15:26+00:00Added an answer on June 17, 2026 at 8:15 am

    Instead of trying to transport multiple pieces of data via the submit button, use a hidden <input>:

    <form ... >
        <input type="hidden" name="unique_id" value="<?php echo htmlspecialchars($row['Unique_id']); ?>" />
    
        ...
    </form>
    

    The ID will be available in $_POST['unique_id'].

    Also consider adding a check to prevent the user from freely setting the amount to change. If you only want to change by 10 or 20 then enforce that with a server side check – currently you are accepting the actual amount to change by, via user input.


    Side note: the mysql_* library is deprecated, it is recommended to upgrade to PDO or MySQLi. Your code is vulnerable to SQL Injection, you should upgrade your MySQLi library and use a Prepared Statement or at least use the appropriate escaping function (mysql_real_escape_string() in this case).

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

Sidebar

Related Questions

I have simple table creating script in Postgres 9.1. I need it to create
I have a simple table. The first column has max-width set at 15px. It
I have a simple table with autoincrementing ID's and one text column. id(int), value(nvarchar)
I have a simple table view which is editable. All I need the user
I have a column in a MYSQL table that accepts TEXT which has HTML
I have simple table in Sybase -- Creating table 'SimpleText' CREATE TABLE [dbo].[SimpleText] (
I have a simple table that has this structure: <table> <thead> <tr> <td>Some info</td>
I have a simple table maintaining messages between users. The table structure looks like
I have a simple table like this <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
I have a simple table in Sybase, let's say it looks as follows: CREATE

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.