[advanced search]
27 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Old 03-11-2007, 09:09 PM   · #1
cotton
New Member
 
Trader Rating: (0)
Join Date: Jan 2007
Posts: 17
NP$: 0.00 (Donate)
cotton is an unknown quantity at this point
php code for inventory system in updating item quantity



recently,im developing an inventory system. the problem is i still dont know how to automatically update the quantity in the stock after the user take the items and how to add the item to the cart as in a shopping cart system. pls help..im using easyphp and i do not use class and function in my system.help me pls...

this is the sample of my code:
<table width="80%" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#CCCCCC">
<tr>
<td width="18%" bgcolor="#E0E2EB"><div align="left">Description : </div></td>
<td width="82%"><? echo $row['description']; ?></td>
</tr>
<tr>
<td bgcolor="#E0E2EB"><div align="left">Item Code : </div></td>
<td><? echo $row['item_code']; ?></td>
</tr>
<tr>
<td bgcolor="#E0E2EB"><div align="left">Category : </div></td>
<td><? echo $row['category']; ?></td>
</tr>
<tr>
<td bgcolor="#E0E2EB"><div align="left">Current quantity : </div></td>
<td><? echo $row['quantity']; ?></td>
</tr>
<tr>

<td bgcolor="#E0E2EB">Required quantity : </td>
<td><input type="text" name="quantity" value="<? echo $row['quantity']; ?>">
<input type="hidden" name="id" value="<? echo $row['quantity']; ?>"></td>

</tr>



</table>


thnx in advance..

i stored the cart in the database..

Anyone..help me pls..i need the code so badly.


Please register or log-in into NamePros to hide ads
cotton is offline   Reply With Quote
Old 03-11-2007, 09:34 PM   · #2
AzN
MiniSite.org Coming Soon!
 
AzN's Avatar
 
Name: ServiceInteract Creatives
Location: San Francisco, CA
Trader Rating: (91)
Join Date: May 2006
Posts: 2,279
NP$: 24.00 (Donate)
AzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond repute
Find Marrow Donors! Ethan Allen Fund Ethan Allen Fund Ethan Allen Fund Save a Life Save a Life Save a Life Save a Life Save a Life Save a Life VA Tech Memorial VA Tech Memorial VA Tech Memorial VA Tech Memorial Save a Life Save a Life Save a Life
You can add upon checkout.
Here's just a sample of what you want to use...
Code:
$item = $_GET['item'] $result = mysql_query("SELECT * FROM inventory WHERE item='$item'") or die(mysql_error()); $row = mysql_fetch_array( $result ); $count = $row['count'] - 1; $result = mysql_query("UPDATE inventory SET count='$count' WHERE item='$item'") or die(mysql_error());
AzN is offline   Reply With Quote
Old 03-12-2007, 01:59 AM   · #3
cotton
New Member
 
Trader Rating: (0)
Join Date: Jan 2007
Posts: 17
NP$: 0.00 (Donate)
cotton is an unknown quantity at this point
thank u very much!! i will try that on..
cotton is offline   Reply With Quote
Old 03-12-2007, 08:54 PM   · #4
cotton
New Member
 
Trader Rating: (0)
Join Date: Jan 2007
Posts: 17
NP$: 0.00 (Donate)
cotton is an unknown quantity at this point
how to show the item in the cart?
cotton is offline   Reply With Quote
Old 03-13-2007, 11:45 PM   · #5
cef
NamePros Regular
 
Location: NYC
Trader Rating: (8)
Join Date: May 2004
Posts: 234
NP$: 75.00 (Donate)
cef is a jewel in the roughcef is a jewel in the roughcef is a jewel in the rough
Animal Rescue
Ack! Never trust user input (e.g., $_POST and $_GET variables). The above code is open to a sql injection.

Replace
PHP Code:
$item = $_GET['item'];
with
PHP Code:
$item = mysql_real_escape_string($_GET['item']);


Also, you might want to check if the item actually exists, and if you have any in stock:
PHP Code:
$row = mysql_fetch_array( $result );

if (
$row === false)
{
        echo
'this item does not exist!';
        return;
// or whatever you need to do
}
else
{
        if (
$row['count']  == 0)
        {
             echo
'sorry, none in stock.';
             return;
// or whatever you need to do
        
}

        
// if you got here you have stock on hand, so continue
        
$count = $row['count'] - 1;
        
// etc...
}
Just a rough draft, but you get the idea.
cef is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


Site Sponsors
http://www.mobisitetrader.com/ http://www.mobisitetrader.com/ Hunting Moon
Advertise your business at NamePros
All times are GMT -7. The time now is 06:29 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0