Okay, I have a database where I have one table which will be the header file of an online order. The second table will be the detail lines of that order. The first table (header) consists of:
order_no - INT 5 auto_increment unique
date - date
store - varchar(2)
the second table (detail) consists of:
order_no - INT 5
id - varchar(5)
sku- varchar(11)
order - varchar(8)
date - date
store - varchar(2)
The first page is a form with the items listed on it and the user will put the quantity for each item they want. The quantity will go into a variable called order. I have it set up to call another script which will create the header file and the detail file. But, when I create the header file with the following:
<?php
//connect to the database
require('inc/database_conn.php');
//get the variables from the other page
$id=$_POST['id'];
$sku=$_POST['sku'];
$description=$_POST['description'];
$order=$_POST['order'];
$store=$_POST['store'];
$date=now();
// create the unique order number
$headerqry = "INSERT INTO misc_order_header (date, store) VALUES ($date, $store)";
mysql_query($headerqry, $conn) or die(mysql_error());
How do I get the new automatically created order_no? Do I have to do a fetch of that data? But, the problem is there could be the same date and same store with different order numbers. How do I know the order number of the line I just inserted?
Thanks for your help,
Jeff