Page 1 of 1

update table issue

Posted: Mon Feb 21, 2011 3:57 am
by batowiise
hi all,

The following is what i want to to achieve;

When the user clicks a button

1. The requistion table should be updated.

2. The store table records should be updated with values from the requisitionitems table and the neccessory deduction be done on the store table.


Step 1 is working fine. However, step 2 is not updating the store table records.

The code is as shown below;

Code: Select all

if (@$_REQUEST['Submit2'] == "Process REQUISITION") { 

		$entryid = $_REQUEST['entryid'];					
		$requisitiondate = $_REQUEST['requisitiondate'];	
		$status = $_REQUEST['status'];
		$department = $_REQUEST['department'];
		$procurementaction = $_REQUEST['procurementaction'];
		$procurementactionname = $_REQUEST['procurementactionname'];
		$systemapprovallist = $_REQUEST['systemapprovallist'];
		$secround = $_REQUEST['secround'];
		
		if(isset($_REQUEST['product']))
		{
		$product = $_REQUEST['product'];
		}

		if(isset($_REQUEST['qtyfigs']))
		{
		$qtyfigs = $_REQUEST['qtyfigs'];
		}

		if(isset($_REQUEST['remarks']))
		{
		$remarks = $_REQUEST['remarks'];
		}


$integer = 0;
					
		
		require_once("../admin/db.php");
		
		$sql_update="UPDATE `requisition` SET
		requisitiondate='$requisitiondate',
		status='PROCESSED',
		department='$department',
		procurementaction='PROCESSED',
		procurementactionname='$fullname',
		systemapprovallist='FINISHED',
		secround='FINISHED'
		WHERE entryid='$entryid'";
	
		// this is where i want to place the store table record update.

		$sql =  "UPDATE stores SET qtyinstock = qtyinstock - '".$qtyfigs[$integer]."'";	
		

		
		
		/* Passes query to database */ 
		
		$result = mysql_query($sql_update); 
		if (!$result) { 
		  echo("<p>Error performing query: " . mysql_error() . "</p><p><a href=\"" . $_SERVER['PHP_SELF'] . "?updaterecord=" .$entryid. "&Submit=Edit\">Click here</a> to return to Problem Log page"); 
		  exit(); 
		} 
		
		else{
			echo"<b>Store Requisition PROCESSED.</b>";
		}

}
I am lost as to how to update the store table records with the values of requisitionitems table.

Your help is welcome.

Thanks.

Re: update table issue

Posted: Mon Feb 21, 2011 8:24 am
by Jsphlane20
1. Do you receive any erorr messages when trying to update the stores table ?

I don't see anything in place to execute the sql query for the store table.