I have a product database containing all the product info.
A form passing variables through in the form $postName = category, $postValue = product id.
I then need to enter the description from products into a table containing the order info such as the descriptions and other info. This means i need to loop through the id's to get all the descriptions, which i am then putting into an array. This array the needs to form part of a query.
Code:
Code: Select all
//this builds the array containing the product descriptions
foreach ($_POST as $postName => $postValue) {
if (($postName>0 && $postName<31) && $postName!='quantity') {
$display = "SELECT * FROM categories,products WHERE categories.cat_id=products.cat_id AND categories.cat_id='$postName' AND prod_id='$postValue'";
$dq = mysql_query($display) or die("Query $display Failed".mysql_error());
$array=array();
$i=0;
while ($type_row=mysql_fetch_object($dq))
{
$array[$i]=',\''.$type_row->desc.'\'';
$i++;
}
}
}
//query
$enterorder = "INSERT INTO orders (orderno,username,dateadded,status,archive,price,exvat,payment,cpu,memory,motherboard,usb,hdd,hdda,raid,cdrom,dvd,dvdw,gcard,gcarda,sound,modem,network,floppy,cardreader,pccase,psu,osreq,firewire,monitor,keyboard,mouse,speakers,printer,virus,office,tvcard,onsite,q,discount,total,totalexvat,deldet,refer,bat,ccase,pbar,l_model,config) VALUES ('','$mail','$datejoined','$type','','$_POST[price]','$_POST[exvat2]','Finance'
//array would go in this bit of the query
,'$_POST[quantity]','$_POST[discount]','$_POST[final]','$_POST[extotal]','$_POST[deldet]','$refer'$array2)";All the post variables such as the prod cats and id's, price and other bits are passed through from an earlier page. As the order table contains product descriptions and price i've had to use the above loop to create the array, missing out some of the posted variables.
Any advice is greatly appreciated.