php网上书城|基于PHP实现网上书店商城藉项目(一)https://developer.aliyun.com/article/1423371
四,核心代码展示
<?php include_once 'conn.php'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>订单</title><script language="javascript" src="js/hsgrili.js"></script><link rel="stylesheet" href="css.css" type="text/css"> </head> <body> <p>已有订单列表:</p> <form id="form1" name="form1" method="post" action=""> 搜索: 订单号:<input name="dingdanhao" type="text" id="dingdanhao" /> 用户名: <input name="jine" type="text" id="jine" /> <input type="submit" name="Submit" value="查找" style='border:solid 1px #000000; color:#666666' /> </form> <table width="100%" border="1" align="center" cellpadding="3" cellspacing="1" bordercolor="#00FFFF" style="border-collapse:collapse"> <tr> <td width="25" bgcolor="#CCFFFF">序号</td> <td bgcolor='#CCFFFF'>订单号</td><td bgcolor='#CCFFFF'>金额</td><td bgcolor='#CCFFFF'>订单内容</td><td bgcolor='#CCFFFF'>用户名</td><td bgcolor='#CCFFFF'>姓名</td><td bgcolor='#CCFFFF'>邮寄地址</td><td bgcolor='#CCFFFF'>邮编</td><td bgcolor='#CCFFFF'>电话</td><td bgcolor='#CCFFFF'>快递类型</td><td bgcolor='#CCFFFF'>快递费用</td> <td width="90" align="center" bgcolor="#CCFFFF">评论管理</td> <td bgcolor='#CCFFFF' width='80' align='center'>是否审核</td> <td width="120" align="center" bgcolor="#CCFFFF">添加时间</td> <td width="70" align="center" bgcolor="#CCFFFF">操作</td> </tr> <?php $sql="select * from dingdan where 1=1"; if ($_POST["dingdanhao"]!=""){$nreqdingdanhao=$_POST["dingdanhao"];$sql=$sql." and dingdanhao like '%$nreqdingdanhao%'";} if ($_POST["jine"]!=""){$nreqjine=$_POST["jine"];$sql=$sql." and yonghuming like '%$nreqjine%'";} $sql=$sql." order by id desc"; $query=mysql_query($sql); $rowscount=mysql_num_rows($query); if($rowscount==0) {} else { $pagelarge=10;//每页行数; $pagecurrent=$_GET["pagecurrent"]; if($rowscount%$pagelarge==0) { $pagecount=$rowscount/$pagelarge; } else { $pagecount=intval($rowscount/$pagelarge)+1; } if($pagecurrent=="" || $pagecurrent<=0) { $pagecurrent=1; } if($pagecurrent>$pagecount) { $pagecurrent=$pagecount; } $ddddd=$pagecurrent*$pagelarge; if($pagecurrent==$pagecount) { if($rowscount%$pagelarge==0) { $ddddd=$pagecurrent*$pagelarge; } else { $ddddd=$pagecurrent*$pagelarge-$pagelarge+$rowscount%$pagelarge; } } for($i=$pagecurrent*$pagelarge-$pagelarge;$i<$ddddd;$i++) { ?> <tr> <td width="25"><?php echo $i+1; ?></td> <td><?php echo mysql_result($query,$i,dingdanhao);?></td><td><?php echo mysql_result($query,$i,jine);?></td><td><?php echo mysql_result($query,$i,dingdanneirong);?></td><td><?php echo mysql_result($query,$i,yonghuming);?></td><td><?php echo mysql_result($query,$i,xingming);?></td><td><?php echo mysql_result($query,$i,youjidizhi);?></td><td><?php echo mysql_result($query,$i,youbian);?></td><td><?php echo mysql_result($query,$i,dianhua);?></td><td><?php echo mysql_result($query,$i,kuaidileixing);?></td><td><?php echo mysql_result($query,$i,kuaidifeiyong);?></td> <td width="90" align="center"><a href="pinglun_list.php?id=<?php echo mysql_result($query,$i,"id");?>&biao=dingdan">评论管理</a></td> <td width='80' align='center'><a href="sh.php?id=<?php echo mysql_result($query,$i,"id") ?>&yuan=<?php echo mysql_result($query,$i,"issh")?>&tablename=dingdan" onclick="return confirm('您确定要执行此操作?')"><?php echo mysql_result($query,$i,"issh")?></a></td> <td width="120" align="center"><?php echo mysql_result($query,$i,"addtime"); ?></td> <td width="70" align="center"><a href="del.php?id=<?php echo mysql_result($query,$i,"id"); ?>&tablename=dingdan" onclick="return confirm('真的要删除?')">删除</a> <a href="dingdan_updt.php?id=<?php echo mysql_result($query,$i,"id"); ?>">修改</a></td> </tr> <?php } } ?> </table> <p>以上数据共<?php echo $rowscount; ?>条, <input type="button" name="Submit2" onclick="javascript:window.print();" value="打印本页" style='border:solid 1px #000000; color:#666666' /> </p> <p align="center"><a href="dingdan_list.php?pagecurrent=1">首页</a>, <a href="dingdan_list.php?pagecurrent=<?php echo $pagecurrent-1;?>">前一页</a> ,<a href="dingdan_list.php?pagecurrent=<?php echo $pagecurrent+1;?>">后一页</a>, <a href="dingdan_list.php?pagecurrent=<?php echo $pagecount;?>">末页</a>, 当前第<?php echo $pagecurrent;?>页,共<?php echo $pagecount;?>页 </p> <p> </p> </body> </html>
<?php $id=$_GET["id"]; include_once 'conn.php'; $ndate =date("Y-m-d"); $addnew=$_POST["addnew"]; if ($addnew=="1" ) { $dingdanhao=$_POST["dingdanhao"];$jine=$_POST["jine"];$dingdanneirong=$_POST["dingdanneirong"];$yonghuming=$_POST["yonghuming"];$xingming=$_POST["xingming"];$youjidizhi=$_POST["youjidizhi"];$youbian=$_POST["youbian"];$dianhua=$_POST["dianhua"];$kuaidileixing=$_POST["kuaidileixing"];$kuaidifeiyong=$_POST["kuaidifeiyong"]; $sql="update dingdan set dingdanhao='$dingdanhao',jine='$jine',dingdanneirong='$dingdanneirong',yonghuming='$yonghuming',xingming='$xingming',youjidizhi='$youjidizhi',youbian='$youbian',dianhua='$dianhua',kuaidileixing='$kuaidileixing',kuaidifeiyong='$kuaidifeiyong' where id= ".$id; mysql_query($sql); echo "<script>javascript:alert('修改成功!');location.href='dingdan_list.php';</script>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>修改订单</title><link rel="stylesheet" href="css.css" type="text/css"><script language="javascript" src="js/hsgrili.js"></script> </head> <script language="javascript"> function OpenScript(url,width,height) { var win = window.open(url,"SelectToSort",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' ); } function OpenDialog(sURL, iWidth, iHeight) { var oDialog = window.open(sURL, "_EditorDialog", "width=" + iWidth.toString() + ",height=" + iHeight.toString() + ",resizable=no,left=0,top=0,scrollbars=no,status=no,titlebar=no,toolbar=no,menubar=no,location=no"); oDialog.focus(); } </script> <body> <p>修改订单: 当前日期: <?php echo $ndate; ?></p> <?php $sql="select * from dingdan where id=".$id; $query=mysql_query($sql); $rowscount=mysql_num_rows($query); if($rowscount>0) { ?> <form id="form1" name="form1" method="post" action=""> <table width="100%" border="1" align="center" cellpadding="3" cellspacing="1" bordercolor="#00FFFF" style="border-collapse:collapse"> <tr><td>订单号:</td><td><input name='dingdanhao' type='text' id='dingdanhao' value='<?php echo mysql_result($query,$i,dingdanhao);?>' /></td></tr><tr><td>金额:</td><td><input name='jine' type='text' id='jine' value='<?php echo mysql_result($query,$i,jine);?>' /></td></tr><tr><td>订单内容:</td><td><textarea name='dingdanneirong' cols='50' rows='8' id='dingdanneirong'><?php echo mysql_result($query,$i,dingdanneirong);?></textarea></td></tr><tr><td>用户名:</td><td><input name='yonghuming' type='text' id='yonghuming' value='<?php echo mysql_result($query,$i,yonghuming);?>' /></td></tr><tr><td>姓名:</td><td><input name='xingming' type='text' id='xingming' value='<?php echo mysql_result($query,$i,xingming);?>' /></td></tr><tr><td>邮寄地址:</td><td><input name='youjidizhi' type='text' id='youjidizhi' size='50' value='<?php echo mysql_result($query,$i,youjidizhi);?>' /></td></tr><tr><td>邮编:</td><td><input name='youbian' type='text' id='youbian' value='<?php echo mysql_result($query,$i,youbian);?>' /></td></tr><tr><td>电话:</td><td><input name='dianhua' type='text' id='dianhua' value='<?php echo mysql_result($query,$i,dianhua);?>' /></td></tr><tr><td>快递类型:</td><td><input name='kuaidileixing' type='text' id='kuaidileixing' value='<?php echo mysql_result($query,$i,kuaidileixing);?>' /></td></tr><tr><td>快递费用:</td><td><input name='kuaidifeiyong' type='text' id='kuaidifeiyong' value='<?php echo mysql_result($query,$i,kuaidifeiyong);?>' /></td></tr> <tr> <td> </td> <td><input name="addnew" type="hidden" id="addnew" value="1" /> <input type="submit" name="Submit" value="修改" style='border:solid 1px #000000; color:#666666' /> <input type="reset" name="Submit2" value="重置" style='border:solid 1px #000000; color:#666666' /></td> </tr> </table> </form> <?php } ?> <p> </p> </body> </html>
<?php session_start(); include_once 'conn.php'; $lb=$_GET["lb"]; if($lb=="") { $lb=$_POST["lb"]; } $biaoti=$_POST["biaoti"]; ?> <!DOCTYPE html> <html> <head> <title>网上书店</title> <LINK type="text/css" rel=stylesheet href="qtimages/style.css"> <script type="text/javascript" src="qtimages/jquery.js"></script> <script type="text/javascript" src="qtimages/arrow.js"></script> <script type="text/javascript" src="qtimages/inc.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head> <body> <?php include_once 'qttop.php';?> <div class="section"> <div class="kcBox clear-fix"> <div class="knowList2 clear-fix"> <div class="Ttitle"><?php echo $lb;?> <span>News</span> <div class="Tmore"> </div> </div> <!-- end Ttitle--> <ul class="knowListUl"> <?php $sql="select * from xinwentongzhi where 1=1"; if ($_GET["biaoti"]!=""){$sql=$sql." and biaoti like '%".$_GET["biaoti"]."%'";} if ($biaoti!=""){$sql=$sql." and biaoti like '%$biaoti%'";} if($lb!=""){$sql=$sql." and leibie='$lb'";} $sql=$sql." order by id desc"; echo $sql; $query=mysql_query($sql); $rowscount=mysql_num_rows($query); if($rowscount==0) {} else { $pagelarge=13;//每页行数; $pagecurrent=$_GET["pagecurrent"]; if($rowscount%$pagelarge==0) { $pagecount=$rowscount/$pagelarge; } else { $pagecount=intval($rowscount/$pagelarge)+1; } if($pagecurrent=="" || $pagecurrent<=0) { $pagecurrent=1; } if($pagecurrent>$pagecount) { $pagecurrent=$pagecount; } $ddddd=$pagecurrent*$pagelarge; if($pagecurrent==$pagecount) { if($rowscount%$pagelarge==0) { $ddddd=$pagecurrent*$pagelarge; } else { $ddddd=$pagecurrent*$pagelarge-$pagelarge+$rowscount%$pagelarge; } } for($i=$pagecurrent*$pagelarge-$pagelarge;$i<$ddddd;$i++) { ?> <li><a href="gg_detail.php?id=<?php echo mysql_result($query,$i,"id");?>"><?php echo mysql_result($query,$i,"biaoti");?></a><span><?php echo substr(mysql_result($query,$i,"addtime"),0,10);?></span> </li> <?php } } ?> <p align="center" class="Page"><a href="news.php?pagecurrent=1&lb=<?php echo $lb;?>">首页</a>, <a href="news.php?pagecurrent=<?php echo $pagecurrent-1;?>&lb=<?php echo $lb;?>">前一页</a> ,<a href="news.php?pagecurrent=<?php echo $pagecurrent+1;?>&lb=<?php echo $lb;?>">后一页</a>, <a href="news.php?pagecurrent=<?php echo $pagecount;?>&lb=<?php echo $lb;?>">末页</a>, <font color="#000000">当前第<?php echo $pagecurrent;?>页,共<?php echo $pagecount;?>页 以上数据共 <?php echo $rowscount; ?> 条,</font> <input name="Submit22" type="button" onclick="javascript:window.print();" value="打印本页" /> </p> </ul> <!-- end knowListUl--> </div> <!-- end knowList--> <div class="contact"> <div class="numTel">400-0000-000</div> <div class="companyConFont"><span style="font-family:Simsun;line-height:30px;"><?php readzd("dx","content","leibie","联系我们");?></span> </div> <div class="conMore"><a href="">更多 +</a></div> </div> <!-- end contact--> </div> <!-- end kcBox--> </div> <?php include_once 'qtdown.php';?> <!-- end footer--> </body> </html>
五,项目总结
研究内容
- 不同用户的登录问题:根据用户的类别(超级管理员、普通用户)实现用户操作权限的区分并显示不同的操作界面。
- 数据库的连接问题:数据库连接为系统中的关键技术。
- 数据的一致性和安全问题:本系统必须保证数据的一致性和安全,才能实现有效的管理。不能让没有权限的用户对数据进行操作并且定期对数据库进行备份。
- 界面开发:系统界面的设计很重要,要使界面具有亲和力。
- 分析网上书店化现状;
- 研究网上书店的现状及存在的问题;
- 研究系统平台的总体架构、总体设计、数据库设计、数据库安全设计及功能设计;
- 研究平台各个子系统的功能及实现的方法、信息技术的融合、信息安全技术的维护;
- 进行网上书店的功能设计。