dongzhi6927 2012-06-11 09:07
浏览 76
已采纳

将数据插入一个表并更新另一个表

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 :)

  • 写回答

1条回答 默认 最新

  • dtng25909 2012-06-11 09:28
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区