|
Posted by shotokan99 on 04/16/07 01:54
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?
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>
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.
Navigation:
[Reply to this message]
|