Jump to content

Problem with script


skoobi

Recommended Posts

Hi what im trying to do is Pull some data from the database then adjust the correct product to update the stock.

 

Heres basicly what im trying to do

 

POS stock table ---> Pull information off an order through a php script...

In the Php script ---> If a Pint or half of a certain beer has been sold it picks up the product id from the orders and then it will check how much has been sold (UNITs) and then it will update the stock of the beer barrell...

 

Ive started on the script but because im not to good at mysql queries and what not ive hit a brick wall where i cant get the product number...

 

Heres what ive got so far...

 

<?php

//Connection
$con = mysql_connect("localhost","my_user","my_password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("my_database", $con);
//End of connection

//Conversion
$convert = '1.7606';

//pint QTY (Litres)
$bCarling ='50.006';
$bGuiness ='50.006';
$bThatchers = '50.006';

//QTY (Litres)
$pint = '0.59';

//Product
$pintCarling = mysql_query("SELECT * FROM ticketlines WHERE PRODUCT='86b5aa37-fb7e-4270-aafb-973938d8db7c'");
$unitCarling = '1';
$pintGuiness = mysql_query("SELECT * FROM ticketlines WHERE PRODUCT='29250bc5-2ab9-4b2c-9c23-edbc7d5c859a'");
$unitGuiness = '2';
$pintThatchers = mysql_query("SELECT * FROM ticketlines WHERE PRODUCT='2f63c736-60e7-4fe9-8fb8-2b56ffcdcfa5'");
$unitThatchers = '2';

//Function
function pintSum($b,$p,$u,$c)
{
$total=($b-($p*$u))*$c;
return $total;
}

//Check Product ID
if ($pintCarling == "bfd1de23-0ebd-4c25-be4f-8bae6de06f4c") echo pintSum($bCarling,$pint,$unitCarling,$convert) . " Pints of Carling Left in the Barrel ";
else echo "<p>No Pints of Carling Been Sold</p>";

if ($pintGuiness == "29250bc5-2ab9-4b2c-9c23-edbc7d5c859a") echo pintSum($bGuiness,$pint,$unitGuiness,$convert) . " Pints of Guiness Left in the Barrel ";
else echo "<p>No Pints of Guiness Been Sold</p>";

if ($pintThatchers == "2f63c736-60e7-4fe9-8fb8-2b56ffcdcfa5") echo pintSum($bThatchers,$pint,$unitThatchers,$convert) . " Pints of Tatchers Left in the Barrel ";
else echo "<p>No Pints of Thatchers Been Sold</p>";


//Close connection
mysql_close($con);
?>

 

Any suggestions would be greatfull as im not a php expert just learning...

 

Cheers

Chris

Link to comment
https://forums.phpfreaks.com/topic/186677-problem-with-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.