Mutliple Submit buttons
Posted: Sun Mar 06, 2011 2:15 am
Hey there! I'm kinda new to PHP and so I have one question... I am curretnly working on admin dashboard for my website where I can pay users for they "work" (i think it's not important what it is for now)... Now I've used this script to get all of the data from the database "payrequest" in a table:

Inside 'pay.php' is a single submit button and form action, this script goes like:
it looks like this:<?php
mysql_connect("localhost","root","root");
mysql_select_db("mydb");
$result = mysql_query("SELECT * FROM payrequest");
{
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Requested by</th>
<th>Amount</th>
<th>Status</th>
</tr>
";
}
while ($row1 = mysql_fetch_array($result))
{
$submit = "<form action='admin_payments.php' method='post'>
<input type='submit' name='pay' value='Pay'>
</form>";
echo "<tr>";
echo "<td>".$row1['id']."</td>";
echo "<td>".$row1['requestby']."</td>";
echo "<td>".$row1['amount']." $</td>";
echo "<td>";
include('pay.php'); //include Pay button for every record
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>

Inside 'pay.php' is a single submit button and form action, this script goes like:
and inside admin_pay_function.php is<form action='admin_pay_function.php' method='post'>
<input type='submit' name='pay' value='Pay'>
</form>
but the problem is, that this script will update all users status 'Paid' and I want to update it just there, where I pressed the "Pay" button and I have no idea how to make it work ... Thank you! (:<?php
session_start();
$user = $_SESSION['username'];
$pay = $_POST['pay'];
if ($user)
{
mysql_connect("localhost","root","root") or die ("DB connexion failed");
mysql_select_db("mydb") or die ("couldnt select db");
mysql_query("UPDATE payrequest SET status='Paid'");
}
?>