Reply
help on online-shopping cart..
Old 04-13-2007, 11:30 PM help on online-shopping cart..
Skilled Talker

Posts: 70
Name: rex
hi pipz,

im working on a simple cart, whenever the user click on "add to cart" link i store the data to mysql. then i display these records using a table and each row i place "remove" link.

my problem is if the user click "remove" how will i tell mysql what record to delete?

can someone pls help me on this?
shotokan99 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-13-2007, 11:42 PM Re: help on online-shopping cart..
Mattmaul1992's Avatar
Ultra Talker

Posts: 440
Name: Matt
You could use the get method. So the link would be to
www.yoursite.com/yourpage.php?act=remove&id=32

Remember $_GET is usually your friend. Or you could use a JavaScript onclick but the problem there is if someone had JavaScript disabled. using the get method is the way to go for an affective, simplistic manner.
__________________
PHP Code:
$talkupation++; 
http://www.forum-front.com/ - Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Old 04-15-2007, 09:49 PM Re: help on online-shopping cart..
Skilled Talker

Posts: 70
Name: rex
this is how i display the contents of the basket of the user...
--------------------------------
<?php
$x=0;
$total=0;
while($x<$num){
echo '<tr>';
$type=mysql_result($result,$x,'citemtype');
$item=mysql_result($result,$x,'cref');
$price=mysql_result($result,$x,'cprice');
$total=$total+$price;

echo '<td width="45" align="center" height="12"><b>';
echo '<font face="Verdana" size="1">'.$type.'</font></b></td>';
echo '<td width="131" align="center" height="12"><b>';
echo '<font face="Verdana" size="1">'.$item.'</font></b></td>';
echo '<td width="54" align="center" height="12"><b>';
echo '<font face="Verdana" size="1">'.$price.'</font></b></td>';
echo '<td width="98" align="center" height="12"><b>';
echo '<font face="Verdana" size="1"><a href="rem.php" style="text-decoration: none">remove</a></font></b></td>';

$x++;
}//end while
?>
---------------

this part is where the user would like to remove a certain item:
echo '<font face="Verdana" size="1"><a href="rem.php" style="text-decoration: none">remove</a>

now where should i place the $_GET here?

currently the contents of rem.php is these:
-------
<html>
<head>
</head>
<body>
<?php
session_start();
$user = $_SESSION['myuser'];
$conn=mysql_connect(.....) or die('server not found');
$db='mydb';
mysql_select_db($db) or die('.: database done exist :.');
$sel="delete from cart where cuser = '$user'";
$result=mysql_query($sel) or die('.: can\'t perform the query :.');
mysql_close();
?>
<script type="text/javascript">
window.location="basket.php";
</script>
</body>
</html>

since i dont know yet how to remove an item individually..i erase them all.
shotokan99 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to help on online-shopping cart..
 

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11476 seconds with 13 queries