Im struggling to do a function like this.In the admin panel of my site,there is an option for the admin to select multiple orders using check boxes and marked them as accepted.And I need to update the product table at the same time according to the product quantities of the selected orders.How should I make this thing happen??
Do I need to put a for loop / a while loop to take the product Ids which need to be update??

Im so glad if some one help me to do this...Please..:)

7 Years
Discussion Span
Last Post by ﻼim

i hope this helps. ;)

$id=base64_decode($_GET['id']); //get the receipt ID and decode to base64
$check = 0;
	if($username == 'admin' && $password == $pass && $id != 0)
		$query3=mysql_query("SELECT * from tbl_customer_order where receipt = $id");
			$query4=mysql_query("SELECT * from tbl_inventory where item_barcode = $obar");
			if($quantity < $oquan)
				echo "<script type='text/javascript'>window.alert('$oname is at Low Quantity!')</script>";
				$check = 1;
		if($check == 0)
			$query=mysql_query("SELECT * from tbl_item_order where receipt = $id"); //select the order
			$query1=mysql_query("SELECT * from tbl_customer_order where receipt = $id"); //select the order
			while($order1=mysql_fetch_object($query1))//get the date from the query
				$query2=mysql_query("SELECT * from tbl_inventory where item_barcode = $cbar"); //select the item from inventory
				mysql_query("UPDATE tbl_inventory set item_quantity = $newquan, item_sold = $newsold, item_profit = $newprofit where item_barcode = $cbar");			
				mysql_query("INSERT into tbl_delivered_item values(null, '$cname', '$idesc', $cbar, '$isup', $iprice, $price, $cquan, '$date', '$ccat', $id)"); //accepted order.insert all the items into the table tbl_delivered_item
			mysql_query("INSERT into tbl_accept_order values(null, $id, '$customer', '$date', $price, $quantity, '$username')"); //accepted order.insert data into the table tbl_accepted_order
			$query3=mysql_query("Select * from tbl_users where username='$customer'"); //update the table tbl_users
			$newquan=$uquan+$quantity; //new quantity of orders in tbl_users
			$newnum=$unum+1; //new number of times ordered in tbl_users
			$newincome=$uincome+$price; //new total income in tbl_users
			mysql_query("UPDATE tbl_users set quantity=$newquan, num_order=$newnum, total_income=$newincome where username = '$customer'");
			mysql_query("UPDATE tbl_customer_order set paid = 1 where receipt = $id");
			mysql_query("UPDATE tbl_item_order set paid = 1 where receipt = $id");
			echo "<script type='text/javascript'>window.alert('Order Accepted!')</script>";
			echo "<META http-equiv='refresh' content='0;URL=orderitems.php'>";
			echo "<META http-equiv='refresh' content='0;URL=orderitems.php'>";



Thanks for your code..But it is still not worked..:(

would you mind showing your code for debugging?
thanks. Ϋ

Edited by ﻼim: missing letter &quot;r&quot; .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.