Jump to content

Stock Keeping


tobimichigan

Recommended Posts

Hello Code Gurus,

Please I am trying to write a web app that keeps track of incoming stocks for products.

Lets assume a product x.

 

In Mysql exits in the Product Table

s/n name quantity

1    x      6

 

Now, I want to add additional quanity of 5 to the exisiting product to make a total of 11.

 

<?php
include ("cn.php");
$select=mysql_query("select * from product);
$row=mysql_fetch_array($select);
$product=$row['product'];

?>

 

I seem to be stuc here, don't know how to increment/decrement the stored quantities in the product table. Please someone kindly help.

Link to comment
Share on other sites

Hello Code Gurus,

Please I am trying to write a web app that keeps track of incoming stocks for products.

Lets assume a product x.

 

In Mysql exits in the Product Table

s/n name quantity

1    x      6

 

Now, I want to add additional quanity of 5 to the exisiting product to make a total of 11.

 

<?php
include ("cn.php");
$select=mysql_query("select * from product);
$row=mysql_fetch_array($select);
$product=$row['product'];

?>

 

I seem to be stuc here, don't know how to increment/decrement the stored quantities in the product table. Please someone kindly help.

 

that one is fairly easy to do just doa  select on the tabl as you were doing it before, do a fetch row and grab teh value you want to modify, then store the updated entry into the table again....

 

 

the plain stupid way which wastes 2 query's to do this  stuff you can however do it with one... but you need to know trough knowledge of  the scripting in mysql....

Link to comment
Share on other sites

but you need to know trough knowledge of  the scripting in mysql....

 

This secret knowledge sangoku is referring to is the query:

 

UPDATE products SET quantity = quantity + 5 WHERE sn = 1

 

Depending on your sort of input there may be better methods

 

LoL

 

Not this one i was thinking if he needs to add a SQL cproc scrpit which would take the values and update them.... When the 5  is a variable XD

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.