⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 order.php

📁 网上书店网站系统
💻 PHP
字号:
<?
function conndb()
{
	$db=@mysql_pconnect("localhost","root","307910");
	if($db==false)
	{
		print "Database failed!";
		exit();
	}
	return $db;
}
function printhead()
{
	print '<html><head><title> 搜索结果</title>';
	print '<meta content="text/html;charset=gb2312" http-equiv=Content-Type></head>';
	require("index.html.inc");
	print '<body><form action=order.php method=post>';//////////////////////////////////////////
	print '<table border=1 sidth="70%" height=200 align=center><tbody>';
}
session_start();
if(!session_is_registered("userorder"))
{
	printhead();
	print "<p align=center>";
	print "You have not log into the shopping system!<br>";
	print "You can <A href=\"main.php\"><cont color=#cc0066>LOGIN";
	print "</font></A> now,or click here to <A href=\"personelinfo.html\"> ";
	print "<font color=#cc0066>REGISTER</font></A> yourself!<br>";
	print "After you have logged in,you can use shopping car freely!";
}
else
{
	$db=conndb();
	if(!strcmp($action,"删除"))
	{
		printhead();
		$res=@mysql_db_query("useorder","delete from $userorder where isdn=$isdn;",$db);
	}
	else if(!strcmp($action,"add"))
	{
		printhead();
		$res=@mysql_db_query("bookseller","select * from $userorder where isdn=$isdn;",$db);
		if(@mysql_num_rows($res)==0)
		{
			@mysql_db_query("bookseller","insert into $userorder values(1,$isdn);",$db);
		}
	}
		else if(!strcmp($botton,"update"))
		{
			printhead();
			$query="select quantity,title from books where isdn=$isdn";
			$res=@mysql_db_query("bookseller",$query,$db);
			$row=@mysql_fetch_row($res);
			if($quantity<=$row[0])
			{
				@mysql_db_query("userorder","update $userorder set quantity=$quantity where isdn=$isdn;",$db);
			}
			else
			{
				print "Book $row[1] has only $row[0] copies in store,but you want $quantity.<br>";
			}
		}

	else if(!strcmp($button,"继续购物"))
	{
		printhead();
		@mysql_db_query("userorder","delete from $userorder;",$db);
	}
	else if(!strcmp($button,"完成购物"))
	{
		header("Location:finish.php");
		exit();
	}
	else
	{
		printhead();
	}
	$res=@mysql_db_query("userorder","select quantity,isdn from $userorder;",$db);
	$num=@mysql_num_rows($res);
	if($num==0)
	{
		print "你还没有订购任何物品!";
	}
	else
	{
		print "<tr><td colspan=5 align=center>购物车</td></tr>\n";
		print "<tr><td>数量</td></tr>书名</td></tr><td>";
		print "价格</td><td>金额</td><td width=20>动作</td></tr>";
		$totalfee;
		for($i=0;$i<$num;$i++)
		{
			$row=@mysql_fetch_row($res);
			$quantity=$row[0];
			$isdn=$row[1];
			print "<tr><td><input type=hidden name=isdn value=$isdn>";
			print "<input type=text size=5 name=quantity value=$quantity></td>";
			$query="select title,price from books";
			$query=$query." where isdn=$row[1]";
			$res2=@mysql_db_query("bookseller",$query,$db);
			$row=@mysql_fetch_row($res2);
			$totalfee+=$quantity*$row[1];
			print "<td>$row[0]</td><td>$row[1]</td>";
			print "<td>".($quantity*$row[1])."</td><td>";
			print "<input type=submit name=button value=删除>";
			print "<input type=submit name=button value=更新>";
			print "</td></tr>\n";
		}
		print "<tr><td colspan=5 align=right>总金额:$totalfee";
		print "&nbsp;&nbsp;</td></tr>";
		print "<tr><td colspan=5>";
		print "<input type=submit name=button value=继续购物>";
		print "&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit name=button value=清空购物车>";
		print "&nbsp;&nbsp;&nbsp;&nbsp;;<input type=submit name=button value=完成购物>";
		print "</td></tr>\n";
	}
}
?>
</tbody></table></form>
<body>
<?
require("foot.html.inc");
?>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -