Jump to content


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


i need help again..

Recommended Posts

again...i have problem in developing the shopping cart...

[b]the database:[/b]

create database product;

create table item(
prodID int(5) not null,
prodName varchar(20),
prodPrice float(6),

insert into item( prodID, prodName, prodPrice)
values(101, 'Kingston', 29.90);

insert into item( prodID, prodName, prodPrice)
values(104, 'Apache', 39.90);

insert into item( prodID, prodName, prodPrice)
values(104, 'Toshiba', 49.90);

insert into item( prodID, prodName, prodPrice)
values(104, 'Panasonic', 39.90);

[b]here is my code:[/b]


<p><CENTER><FONT SIZE=+3 FONT COLOR="gold" FACE="Arial"><b><marquee>PRODUCTS ....


or die ('Unable to connect');

mysql_select_db('product') or die ('Unable to select database!');

$query='SELECT*FROM item';
or die ('Error in query:$query.'.mysql_error());

if (mysql_num_rows($result)> 0)
<table border="1" align=center>




echo'<tr><td><a href="description.html"><img src="1.jpg" height="130" width="140"

echo '<td>'.$Id. '</td>';
echo '<td>'.$prod[$Id]['desc'] . '</td>';
echo '<td>'.$prod[$Id]['price'] . '</td>';
echo '<td><form action="cart.php" method="POST">
<input size=3 type="text" name=\"a_qty[".$Id."]\"></td>';
echo '</tr>';
<tr><td colspan="3"></td>
<td colspan="2"><input type="submit" name="add" value="Add items to cart"></td>

echo 'No rows Found!';

actually...i have no problem with the code above... but can i know... how can i get the quantity being insert in the form...and sent the input into database..??... wat should i do the next?...i mean how can i get the data from the customer after the click "add items to cart" ...??

the assignment question is like this -->

2. Shopping Cart Module(15 Marks)
a. Display the list of products available for the user to buy online. (5 Marks)
b. If he selects items put them in the shopping cart. And display the list of items selected by the customer along with its cost. (5 Marks)
c. Allow the customer to update or clear the shopping cart. (5 Marks)

i have been stucked here..can any1 help me??..please.........




Share this post

Link to post
Share on other sites
I hate to be a prick but, inserting data into the db, is one of the very basics of PHP/MySQL.

My suggestion, is to check out :

[a href=\"http://www.php.net\" target=\"_blank\"]http://www.php.net[/a]

[a href=\"http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html[/a]

Good luck with what appears to be, your assignment.

Share this post

Link to post
Share on other sites
well you should have another table to hold the items in the cart. This table should contain an auto_increment field, customer_id, item_id, quantity, and maybe a status field.

When you click add to cart you should go to the shopping cart page and that is where you enter in the data into the new table.

Before you can do this you need to make sure the values you need are in between the <form> tags. Right now you item id is not.

Not sure what else to tell you other than writing it for you.


Share this post

Link to post
Share on other sites

so...i need to have a new table in my database to accept all the input fr the form and then displaying all the items that the customer's select in the new page......this new page is taking the data from the new table...right??...calculation can be done within this page ya??....coz i need to sum up all the items' cost...

the customer_id in the new table... should i get the data from the session of that page ??...or some where else?....

actually... im quite slow in learning... sorry...

hope u can give me more ideas.....

thanks a lot...


Share this post

Link to post
Share on other sites


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.