Jump to content

update table issue

- - - - -

  • Please log in to reply
1 reply to this topic

#1
batowiise

batowiise

    Newbie

  • Members
  • PipPip
  • 17 posts
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;


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.

#2
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
You have to explain the structure and relationship between the tables. Currently we have no idea how to tie items in requisition table with items in requisitionitems and also with stores table. Even in $sql_update you did not refer to requisitionitems table.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users