All pastes #406530 Raw Edit

Unnamed

public php v1 · immutable
·published 2007-03-22 14:36 UTC
rendered paste body
<?php	$link = mysql_connect('localhost','root','') or die ("Unable to connect ".mysql_error());	mysql_select_db("funghit") or die("Unable to find database ".mysql_error());		//database selected, let's set the Query and continue		// now let's retrieve the form field values and prepare to insert	$data_intrare = htmlspecialchars($_POST['DataIn']);	$nume_material = htmlspecialchars($_POST['NumeMaterial']);	$cantitate = htmlspecialchars($_POST['Cantitate']);	$nume_furnizor = htmlspecialchars($_POST['NumeFurnizor']);		//am preluat datele, acum sa vrificam daca exista materlialul	//folosim in query de select	$materialQuery = "SELECT nume_material,nume_furnizor,cantitate FROM stoc_total WHERE nume_material LIKE '".$nume_material."' AND nume_furnizor LIKE '".$nume_furnizor."'";	$result = mysql_query($materialQuery,$link) or die("Unable to execute Query".mysql_error());	$numberOfRecords = mysql_num_rows($result);	if($numberOfRecords != 0)	{		$cantitateNoua = 0;		while($row = mysql_fetch_row($result))		{			$cantitateNoua = $row[2]+$cantitate;		}		$updateQuery = "UPDATE stoc_total SET cantitate = ".$cantitateNoua." WHERE nume_material LIKE '".$nume_material."' AND nume_furnizor LIKE '".$nume_furnizor."'";		$insertIntrari = "INSERT INTO stoc_intrari(id,data_intrare,nume_material,cantitate,nume_furnizor) VALUES('".$data_intrare."','".$nume_material."','".$cantitate."','".$nume_furnizor."')";		$updateStTotal = mysql_query($updateQuery,$link) or die("Unable to execute Update ".mysql_error());		$insertStIntrari = mysql_query($insertIntrari,$link) or die("Unable to perform INSERT ".mysql_error());	}	elseif($numberOfRecords == 0)	{		$insertStTotQuery = "INSERT INTO stoc_total(id,nume_material,nume_furnizor,cantitate,um,data_intrare,data_epuizare) VALUES ('".$nume_material."','".$nume_furnizor."','".$cantitate."',' ','".$data_intrare."','0000-00-00')";		$insertIntrari = "INSERT INTO stoc_intrari(id,data_intrare,nume_material,cantitate,nume_furnizor) VALUES ('".$data_intrare."','".$nume_material."','".$cantitate."','".$nume_furnizor."')";		$insertStTot = mysql_query($insertStTotQuery,$link) or die("Unable to update the table ".mysql_error());		$insertStIntrari = mysql_query($insertIntrari,$link) or die("Unable to perform INSERT ".mysql_error());			}	?>