<?php
require_once "Dao.php";
session_start();
$connect = new PDO("mysql:host=us-cdbr-iron-east-05.cleardb.net;dbname=heroku_aff9d2e3ac3a5cb", "b680ccbbe5db1a", "06bf65d1");
$message = '';
if (isset($_POST["add_to_cart"])) {
if (isset($_COOKIE["shopping_cart"])) {
$cookie_data = stripslashes($_COOKIE['shopping_cart']);
$cart_data = json_decode($cookie_data, true);
} else {
$cart_data = array();
}
$item_id_list = array_column($cart_data, 'item_id');
if (in_array($_POST["hidden_id"], $item_id_list)) {
foreach ($cart_data as $keys => $values) {
if ($cart_data[$keys]["item_id"] == $_POST["hidden_id"]) {
$cart_data[$keys]["item_quantity"] = $cart_data[$keys]["item_quantity"] + $_POST["quantity"];
}
}
} else {
$item_array = array(
'item_id' => $_POST["hidden_id"],
'item_name' => $_POST["hidden_name"],
'item_price' => $_POST["hidden_price"],
'item_quantity' => $_POST["quantity"]
);
$cart_data[] = $item_array;
}
$item_data = json_encode($cart_data);
setcookie('shopping_cart', $item_data, time() + (86400 * 30));
header("location:OrderInfo.php?success=1");
}
if (isset($_GET["action"])) {
if ($_GET["action"] == "delete") {
$cookie_data = stripslashes($_COOKIE['shopping_cart']);
$cart_data = json_decode($cookie_data, true);
foreach ($cart_data as $keys => $values) {
if ($cart_data[$keys]['item_id'] == $_GET["id"]) {
unset($cart_data[$keys]);
$item_data = json_encode($cart_data);
setcookie("shopping_cart", $item_data, time() + (86400 * 30));
header("location:OrderInfo.php?remove=1");
}
}
}
if ($_GET["action"] == "clear") {
setcookie("shopping_cart", "", time() - 3600);
header("location:OrderInfo.php?clearall=1");
}
}
if (isset($_GET["success"])) {
$message = '
<div class="alert alert-success alert-dismissible">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Item Added into Cart
</div>
';
}
if (isset($_GET["remove"])) {
$message = '
<div class="alert alert-success alert-dismissible">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Item removed from Cart
</div>
';
}
if (isset($_GET["clearall"])) {
$message = '
<div class="alert alert-success alert-dismissible">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
Your Shopping Cart has been clear...
</div>
';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>OrderInfo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/header_bg.css">
<link rel="stylesheet" href="css/OrderInfo.css">
<link rel="stylesheet" href="css/footer.css">
<link rel="stylesheet" href="css/shoplist.css" />
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="js/OrderInfo.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<?php include 'header.php'; ?>
<div class="bg">
<div class="top">
<div class="user">
<div id="name">
<span>User Name</span>
<div class="topbar" hidden>
<ul>
<li>
<div class="topbar_item">
<a href="profile.php"><span>Profile</span></a>
</div>
</li>
<li>
<div class="topbar_item">
<a href="profile.php"><span>User</span></a>
</div>
</li>
<li>
<div class="topbar_item">
<a href="profile.php"><span>My Address</span></a>
</div>
</li>
<li id="u5" class="topbar_item">
<div>
<a href="signInUp.php"><span>Sign out</span></a>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
<br />
<div class="container">
<br />
<br /><br />
<?php
$query = "SELECT * FROM product ORDER BY id ASC";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach ($result as $row) {
?>
<div class="col-md-3">
<form method="post">
<div style="border:1px solid #333; background-color:#f1f1f1; border-radius:5px; padding:16px; height: 400px; max-width: 200px;" >
<img src="images/<?php echo $row["image"]; ?>" class="img-responsive" /><br />
<h4 class="text-info"><?php echo $row["name"]; ?></h4>
<h4 class="text-danger">$ <?php echo $row["price"]; ?></h4>
<input type="text" name="quantity" value="1" class="form-control" />
<input type="hidden" name="hidden_name" value="<?php echo $row["name"]; ?>" />
<input type="hidden" name="hidden_price" value="<?php echo $row["price"]; ?>" />
<input type="hidden" name="hidden_id" value="<?php echo $row["id"]; ?>" />
<input type="submit" name="add_to_cart" style="margin-top:5px;" class="btn btn-success" value="Add to Cart" />
</div>
</form>
</div>
<?php
}
?>
<div style="clear:both"></div>
<br />
<h3>Order Details</h3>
<div class="table-responsive">
<?php echo $message; ?>
<div align="right">
<a href="OrderInfo.php?action=clear"><b>Clear Cart</b></a>
</div>
<table class="table table-bordered">
<tr>
<th width="40%">Item Name</th>
<th width="10%">Quantity</th>
<th width="20%">Price</th>
<th width="15%">Total</th>
<th width="5%">Action</th>
</tr>
<?php
if (isset($_COOKIE["shopping_cart"])) {
$total = 0;
$cookie_data = stripslashes($_COOKIE['shopping_cart']);
$cart_data = json_decode($cookie_data, true);
foreach ($cart_data as $keys => $values) {
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>$ <
没有合适的资源?快使用搜索试试~ 我知道了~
使用HTML CSS PHP mySQL JavaScript 开发的水果购物商城系统完整源码+数据库+项目说明.7z
共41个文件
php:12个
css:10个
jpg:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 3 下载量 78 浏览量
2022-12-17
22:01:28
上传
评论 8
收藏 7.33MB ZIP 举报
温馨提示
使用HTML CSS PHP mySQL JavaScript 开发购买水果的网络商城系统完整源码+数据库+项目说明.7z 一个水果购物网站,带数据库 【备注】 主要针对计算机相关专业的正在做毕设的学生和需要项目实战的PHP 、HTML 学习者。 也可作为课程设计、期末大作业。包含:项目源码、数据库脚本、项目说明等,该项目可以直接作为毕设使用。 也可以用来学习参考借鉴!
资源推荐
资源详情
资源评论
收起资源包目录
使用HTML CSS PHP mySQL JavaScript 开发购买水果的网络商城系统完整源码+项目说明.zip (41个子文件)
项目说明.md 124B
src
www
shoplist.php 5KB
Dao.php 2KB
header.php 652B
js
jquery-ui.min.js 248KB
OrderInfo.js 1012B
jquery-3.4.1.min.js 274KB
jquery-1.12.4.js 287KB
login-handler.php 1KB
footer.php 2KB
img
ins.png 3KB
lemon.jpg 38KB
pear.jpg 5.81MB
fb.png 2KB
apple.jpg 53KB
apple.jpeg 69KB
orange.jpg 38KB
banana.jpg 1.01MB
logo.jpg 145KB
signup.php 4KB
css
style_index.css 2KB
jquery-ui.min.css 31KB
footer.css 2KB
home.css 5KB
style_shoplist.css 1KB
header_bg.css 643B
shoplist.css 3KB
OrderInfo.css 3KB
recruitment.css 174KB
signInUp.css 1KB
index.php 1KB
OrderInfo.php 9KB
profile.php 2KB
signup_handler.php 2KB
signIn.php 2KB
db
config.php 243B
.gitkeep 0B
create-table.sql 2KB
composer.json 0B
docs
.gitkeep 0B
Procfile 44B
共 41 条
- 1
资源评论
- 2301_786672852023-06-19资源不错,很实用,内容全面,介绍详细,很好用,谢谢分享。
- SamC1126122023-05-05这个资源值得下载,资源内容详细全面,与描述一致,受益匪浅。Make程序设计2023-06-12感谢支持~
Make程序设计
- 粉丝: 5723
- 资源: 3570
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 51单片机学习(1)-软件keil下载
- 历届(第1-21届)希望杯数学竞赛初一试题及答案(最新整理).doc全国数学邀请赛(264页资料)
- 水滴.psd
- TokenPocket_V2.1.2_release.apk
- Apache-druid-kafka-rce.yaml
- 基于C#的ASP.NET数据库原理及应用技术课程指导平台的开发
- 基于ROS的智能车轨迹跟踪算法的仿真与设计源码运用PID跟踪算法.zip.zip
- Bug Bounty Tip - i春秋Self-XSS变废为宝的奇思妙想
- 1991-2015年全国初中化学竞赛复赛试题汇编(212页)(24年竞赛复赛真题).docx天原杯
- Apache Flink 未授权访问+远程代码执行.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功