TonyE
|
| Posted: 04/22/2002, 9:45 AM |
|
In my application, users can order spare-parts online similar to the bookstore application. The selected spare-parts and Quantities are stored in the orders table.
On the final checkout page I have an Entry form for a PO# and additional shipping information. This information is stored in a different table called purch_info.
After the submit button is pushed, I want to execute the following sequences in the [after insert events].
1. Retrieve the auto increment value info_id from the purch_info table.
$infoID = mysql_insert_id();
2. Put that value into a session variable
session_register("infoID");
3. (This is the step that I cannot figure out)
Copy the records from the "orders" table into the "purchased" table, adding the info_id value from the "purch_info" table to it. The records from the orders table are filtered by company_Id retrieved from a session variable.
The variable works if I leave the info_id field out.
$db->query("insert into purchases (item_id, company_id, user_id, quantity) select item_id, company_id, user_id, quantity from orders where company_id=".get_session("CompID"));
I can not figure out, on how to add the additional info_id value retrieved from sesssion to the above copy process.
Does anybody have a clue on how to do this?
I am using mysql and php.
|
|
|
 |
Brent
|
| Posted: 04/22/2002, 11:34 AM |
|
try:
$db->query("insert into purchases (item_id, company_id, user_id, quantity, info_id) select item_id,
company_id, user_id, quantity, $infoID from orders where company_id=".get_session("CompID"));
Don't forget, MySQL's Select statement can display constants, like
select 1 from table;
Now you're kicking yourself, right? <g>
|
|
|
 |
|