You are here: help on online-shopping cart.. « PHP Programming Language « IT news, forums, messages
help on online-shopping cart..

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация