Jump to content

i need help again..


irene169

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),
PRIMARY KEY (prodID)
)TYPE = MyISAM;

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]




<html>
<head>
<title>Products</title>

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

PRODUCTS .... PRODUCTS</marquee></b></FONT><CENTER>

<?php
$connection=mysql_connect('localhost','root')
or die ('Unable to connect');

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

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

if (mysql_num_rows($result)> 0)
{
?>
<table border="1" align=center>
<tr><td>&nbsp</td><td><b>ID</b></td><td><b>NAME</b></td><td><b>PRICE</b></td><td><

b>Quantity</b></td></tr>

<?php
while($row=mysql_fetch_row($result))

{
$Id=$row[0];
$prod[$Id]['desc']=$row[1];
$prod[$Id]['price']=$row[2];

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

align="left"></td>';
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>
</form>
</table>

<?php
}
else
{
echo 'No rows Found!';
}
mysql_free_result($result);
mysql_close($connection);
?>
</body>
</head>
</html>


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



thanks

regards...

irene


Link to comment
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.
Link to comment
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.

Ray
Link to comment
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...

regards..
irene

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.