Forum Moderators: coopster
ISSUE 1:
They have created a table that would use a unique id AutoIncrement so that each quote would essentially be the last entry +1. Though I'm wondering if there is a way to reference the form's number as it is submitted, maybe to somehow look up the greatest number and then add 1 to it or something?
ISSUE 2:
One variable in my form is basically an array that holds the order information, i.e. all orders and there pricing per item, total, etc. I'm wondering how I could go about saving this array in MySQL. It contains numbers, words, and even a short description. maybe I could save each seperate array element into a different column or something but it is important to note that the array size varies because there are different numbers of orders.
Possible Solution: I think I can overcome this by having a seperate table for orders. If order 1 had 5 items, the Order ID Number 1 would be entered 5 times, with all of its information for each individual part, and I'd have to retrieve the 5 rows. So I think that would work.
Thanks so much for your help :)
ISSUE 2:
One variable in my form is basically an array that holds the order information, i.e. all orders and there pricing per item, total, etc. I'm wondering how I could go about saving this array in MySQL. It contains numbers, words, and even a short description. maybe I could save each seperate array element into a different column or something but it is important to note that the array size varies because there are different numbers of orders.
Possible Solution: I think I can overcome this by having a seperate table for orders. If order 1 had 5 items, the Order ID Number 1 would be entered 5 times, with all of its information for each individual part, and I'd have to retrieve the 5 rows. So I think that would work.Thanks so much for your help :)
Exsactly
What you have is a one-many relivence. so you need 2 tables in your DB
One with the order info and another with the items/price/discription ect.
in the second you would have something like
orderid ¦ product ¦ price ¦ discription
or you could make it even more streamlined by having 3 tables
one would be
id ¦ product name ¦ price ¦ discription
then the other would be
orderid ¦ productid
of course if you change your price or discription you might have to create a new entery so that you can perserve the old order data So you can go back and easily check to see what the price was at time of purchace.
mysql_connect ("#*$!x", "#*$!x", "#*$!x") or die ('Could not connect to the database because: ' . mysql_error());
mysql_select_db ("quoteDatabase") or die ('Could not select database');
$result = MYSQL_QUERY("INSERT INTO customerMaster (order_Num, territory, salesRep, repEmail, facility, address, contact1, department1, phone1, fax1, email1, contact2, department2, phone2, fax2, email2, comments, gpo, otherDiscount)".
"VALUES('NULL', '$territory', 'salesRep', '$repEmail', '$address', '$contact1', '$department1', '$phone1', '$fax1', '$email1', '$contact2', '$department2', '$phone2', '$fax2', '$email2', '$comments', '$gpo', '$otherDiscount')");
mysql_close();
[edited by: jatar_k at 6:01 pm (utc) on June 21, 2005]
[edit reason] fixed sidescroll [/edit]
$result = MYSQL_QUERY("INSERT INTO customerMaster SET
order_Num='NULL', (although this should be auto so you just wouldn't have this line right?)
territory= '$territory',
salesRep= 'salesRep',
repEmail= '$repEmail',
facility=
address= '$address',
contact1= '$contact1',
department1= '$department1',
phone1= '$phone1',
fax1= '$fax1',
email1= '$email1',
contact2= '$contact2',
department2= '$department2',
phone2= '$phone2',
fax2= '$fax2',
email2= '$email2',
comments= '$comments',
gpo= '$gpo',
otherDiscount='$otherDiscount'");
This way you can also make sure there are no mistakes like with 'facility'
Sarah