Home » questions » MySQL insert then update in PHP on submit ? how?

MySQL insert then update in PHP on submit ? how?

2006-08-04 06:49:56, Category: Programming & Design
i am inserting into a table and want to update a field in another one, how can i add update statement into $insertSQL = sprintf("INSERT INTO sellbuytable (AccountNo, StockSympol, TraDate, Sell, Buy, Price, Commition, Broker) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['AccountNo'], "text"), GetSQLValueString($_POST['Symbol'], "text"), GetSQLValueString($_POST['tradate'], "date"), GetSQLValueString($_POST['sell'], "double"), GetSQLValueString($_POST['buy'], "double"), GetSQLValueString($_POST['Price'], "double"), GetSQLValueString($_POST['commition'], "double"), GetSQLValueString($_POST['broker'], "text"));

Answers

  1. look

    On 2006-08-04 06:54:19


    da um isere ççç csdfakjkjkjkwjer adsfaf fasdf gggeeartt get de num sei o q ai mais um do get ai depois tu double ai ai tu via no value!!
  2. rob

    On 2006-08-04 07:04:22


    $sql="INSERT INTO sellbuytable (AccountNo, StockSympol, etc) VALUES('$_POST[AccountNo]','$_POST['StockSymbol'],etc)"; $res=mysql_query($sql); $sql2="UPDATE table SET whatever='whatever' WHERE whatever='whatever'"; $res2=mysql_query($sql2);
  3. A A

    On 2006-08-04 07:58:56


    Rob, above has it, you don't have an UPDATE statement
  4. thegooddeal2000

    On 2006-08-04 06:57:52


    You would probably be best off using MySQL Stored Procedures. They are very good at handling that type of thing. The more that you have handled within MySQL rather than in your code, the less resources your program is going to require. If you choose not to go that way, I would just fire off the two commands seperately. It's "clunkier" but, for the most part, will give the same result.