I have 2 different tables project
and payments
. When I insert a payment I want the value of flag
from the project
table to be changed to paid
if the $money inserted
are exactly the same as the value of cost
(cost
is another cell from the project
table) and the $order = proj_name
.
Here comes the code!
<?php
include("connect.php");
// define variables
$name = $_POST['name'];
$order = $_POST['order'];
$money = $_POST['money'];
$date = $_POST['date'];
$sql="INSERT INTO payments VALUES
('','$name','$order','$money','$date')";
$s="UPDATE project SET flag='payed' WHERE proj_name='$order' AND cost like '%money%'";
mysql_query($s);
echo '<center>' ."Payment stored successfully". '</center>';
echo '<center>'."<a href='payments_edit.php'>View Changes</a>".'</center>';
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close();?>
If you want any more info on anything let me know :)