update table issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
batowiise
Forum Commoner
Posts: 28
Joined: Fri Dec 17, 2010 7:11 am

update table issue

Post 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.
Jsphlane20
Forum Newbie
Posts: 17
Joined: Wed Aug 11, 2010 1:17 pm
Contact:

Re: update table issue

Post 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.
Post Reply