帮助在线购物车.. [英] help on online-shopping cart..

查看:59
本文介绍了帮助在线购物车..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨pipz,


我正在使用简单的购物车,每当用户点击添加到购物车时

链接我将数据存储到MySQL的。然后我使用

表显示这些记录,我放置的每一行删除链接。


我的问题是,如果用户点击删除链接我怎么告诉mysql什么

记录要删除?


这是我如何显示用户购物篮的内容......

--------------------------------

<?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"对齐= QUOT;中心" height =" 12">< b>'';

echo''< font face =" Verdana" size =" 1">''。$ type。''< / font>< / b>< / td>'';

echo''< td width = " 131"对齐= QUOT;中心" height =" 12">< b>'';

echo''< font face =" Verdana" size =" 1">''。$ item。''< / font>< / b>< / td>'';

echo''< td width = " 54"对齐= QUOT;中心" height =" 12">< b>'';

echo''< font face =" Verdana" size =" 1">''。$ price。''< / font>< / b>< / td>'';

echo''< td width = " 98"对齐= QUOT;中心" height =" 12">< b>'';

echo''< font face =" Verdana" size =" 1">< a href =" rem.php" style =" text-

decoration:none"> remove< / a>< / font>< / b>< / td>'';


$ x ++;

} //结束时

?>

---------- -----


这部分是用户想要删除某个项目的地方:

echo''< font face =" Verdana" ; size =" 1">< a href =" rem.php" style =" text-

decoration:none"> remove< / a>


目前rem.php的内容是:

-------

< html>

< head>

< / head>

< body>

<?php

session_start();

$ user = $ _SESSION [' 'myuser''];

$ conn = mysql_connect(.....)或死(''找不到服务器');

$ db ='' mydb'';

mysql_select_db($ db)或死('':数据库已存在:。'');

$ sel ="从购物车中删除cuser =''$ user''" ;;

$ result = mysql_query($ sel)或die('':can can不执行查询:。'');

mysql_close();

?>

< script type =" text / javascript">

window.location =" basket.php";

< / script>

< / body>

< / html> ;


因为我还不知道如何删除项目单独..我删除它们

all。

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.

推荐答案

x = 0;
x=0;


total = 0;

while(
total=0;
while(


x<


这篇关于帮助在线购物车..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆