Insert data into one table and update another

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!

 // define variables
 $name = $_POST['name'];
 $order = $_POST['order'];
 $money = $_POST['money'];
 $date = $_POST['date'];

 $sql="INSERT INTO payments VALUES

 $s="UPDATE project SET flag='payed' WHERE proj_name='$order' AND cost like '%money%'";
 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());


If you want any more info on anything let me know :)


You are missing $ in AND cost like '%money%'. It should be AND cost like '%$money%'

Need Your Help

Should entities from Core Data be strong or weak properties when using ARC?

objective-c memory-management automatic-ref-counting

I've been confused about core data entities. Since you never allocate them do you need to retain them? When a view controller has an entity as one of its properties should it be weak when another v...

Rails Console find users by array of ids

mysql ruby-on-rails ruby postgresql rails-console

So I have an array of user ids. Is there a way in rails console to query all of these user's with the array