|
|
|
รบกวนช่วยดูระบบตะกร้าให้ทีค่ะ คลิกแล้วไม่แสดงข้อมูล รบกวนทีนะคะ |
|
|
|
|
|
|
|
จาก code ด้านล่างค่ะ
www.kwbabyshop.com กดตรงเพิ่มสินค้าลงตะกราแล้ว ชื่อสินค้า ราคา ไม่ขึ้นค่ะ ตรวจสอบ ฟิลด์จากฐานข้อมูลก็ถูกต้องทุกอย่าง รบกวนช่วยทีนะคะ งมมาสองวันก็ยังไม่ได้ค่ะ
ขอบคุณมาก ๆ ค่ะ
Code (PHP)
<?
session_start();
require_once "connectdb.php";
//$productid = $_REQUEST['productid'];
//$act = $_REQUEST['act'];
$product_id = $_REQUEST['productid'];
$act = $_REQUEST['act'];
if($act=='add' && !empty($product_id))
{
if(isset($_SESSION['cart'][$product_id]))
{
$_SESSION['cart'][$product_id]++;
}
else
{
$_SESSION['cart'][$product_id]=1;
}
}
if($act=='remove' && !empty($product_id)) //ยกเลิกการสั่งซื้อ
{
unset($_SESSION['cart'][$product_id]);
}
if($act=='update')
{
$amount_array = $_POST['amount'];
foreach($amount_array as $product_id=>$amount)
{
$_SESSION['cart'][$product_id]=$amount;
}
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="<? echo "$descr"; ?>">
<meta name="keywords" content="<? echo "$keyw"; ?>">
<title><? echo "$headerweb"; ?></title>
<link href="mycss/bootstrap.min.css" rel="stylesheet">
<link href="stylefonts.css" rel="stylesheet">
<link href="stylecustom.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Taviraj" rel="stylesheet">
<link href="mycss/ie10-viewport-bug-workaround.css" rel="stylesheet">
<link href="mycss/stylesheet.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="myjs/ie8-responsive-file-warning.js"></script>
<script src="myjs/ie-emulation-modes-warning.js"></script>
<link rel="stylesheet" type="text/css" href="myjs/jquery-ui/jquery-ui.min.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link rel="stylesheet" href="css/simplePagination.css" />
<script src="js/jquery.simplePagination.js"></script>
<style>
body{
/*background:#000000; */
background:url("configimg/<? echo "$background"; ?>");background-repeat:no-repeat;
background-size:cover;
/*background-color:#ff0000;*/
background-attachment:fixed;
}
#bgtopheader{
background-color: #000000;
margin: 0px;
width:100%;
}
#bgheader{
background-color: #201f1f;
margin-top: 0px;
width:100%;
}
#bgslide{
width:100%;
}
#bxdetail{
width:100%;
background-color: #fff;
}
#bgwebbody{
background-color: #181818;
}
.bgfixs {
width: 100%;
height:50px;
padding: 10px;
border-style:none;
border:0px;
background-image: url("images/bgfixtures.png");
background-size:100% 100%;
/*color:white; */
}
.itemsbx{
float:left;
width:100%;
padding:10px;
margin-left:9px;
background: #04202c;
border:1px solid #144964;
color:#fff;
text-shadow:none;
}
@media screen and (max-width: 600px) {
#bggr{
background-color: #0a170a;
margin-top: 0px;
width:100%;
}
}
.subject{
color:#f5f021;
font-weight:bold;
font-size:16px;
}
.description{
font-size:14px;
color:#eee;
}
.item-wrapper {
height:320px;
}
div.img-resize img {
width: 100%;
height: 190px;
height: auto;
}
div.img-resize {
width: 100%;
height: 190px;
overflow: hidden;
text-align: center;
}
</style>
</head>
<div class="container"style="margin-top:0px;">
<div class="row">
<a href=<? echo "$website"; ?>/><img src=configimg/<? echo "$logoweb"; ?> class=img-responsive border="0"></a>
</div>
<div class="row">
<? require_once "navmenu.php"; ?>
</div>
<div class="row">
<? require_once "slideshow.php"; ?>
</div>
<div class="row" style="background-color:#fff;padding:10px;">
<!-- เปิด Column ซ้าย-->
<div class="col-md-3">
<div align="center" class="row" style="background-color:#000;padding:10px;"> <!-- หมวดสินค้า -->
<font color=#ffffff size=4>หมวดสินค้า</font>
</div> <!-- ปิดหมวดสินค้า -->
<div class="row">
<table class="table table-bordered">
<?
$num=1;
$limit = 10;
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $limit;
$sql = "SELECT * FROM categorytb ORDER BY id asc LIMIT $start_from, $limit";
$rs_result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($rs_result)) {
$idcate = $row['id'];
$catename = $row['catename'];
$sqlnumcate="select * from producttb where cateid = '$idcate'";
$query_select=mysqli_query($conn,$sqlnumcate);
$num_rows=mysqli_num_rows($query_select);
?>
<tr><td><a href=cate-<? echo "$idcate"; ?>><font color=#000000 size=3><? echo "$catename"; ?></font></a> <font color=#666666 size=3><? echo "($num_rows)"; ?></td></tr>
<?
$num = $num+1;
}
?>
</table>
</div>
<div align="center" class="row hidden-xs" style="padding-top:10px;">
<? echo "$fanpage"; ?>
</div>
<div align="center" class="row hidden-xs" style="padding-top:10px;">
<img src=images/transban.png class="img-responsive">
</div>
<div align="center" class="row hidden-xs" style="padding-top:10px;">
<a href=http://track.thailandpost.co.th/tracking/default.aspx target="_blank"><img src=images/emsban.png class="img-responsive" border="0"></a>
</div>
<div align="center" class="row hidden-xs" style="padding-top:10px;">
<a href=https://th.kerryexpress.com/th/track/ target="_blank"><img src=images/kerryban.png class="img-responsive" border="0"></a>
</div>
</div>
<!-- ปิด Column ซ้าย-->
<div class="col-md-9"> <!-- เปิด Column ขวา-->
<div class="row" style="padding:10px;">
<?
$sqllv="select * from welcometb where id=1";
$db_query=mysqli_query($conn,$sqllv);
$resultlv=mysqli_fetch_array($db_query);
$msgtalk=$resultlv[message];
echo "<font color=#000000 size=5>แวะพัก..ทักทาย</font><br><font color=#736e6e size=3>$msgtalk</font>";
?>
</div>
<div class="row" style="padding-top:10px;">
<img src=images/lineban.png class="img-responsive">
</div>
<div class="row" style="padding-top:10px;">
<font color=#003366 size=5><b>xxxx</b></font><hr>
</div>
<div class="row" style="padding-top:10px;padding:15px;background-color:#e5e7e2;">
<form id="frmcart" name="frmcart" method="post" action="?act=update">
<table width="100%" border="0" align="center" class="square">
<tr>
<td colspan="5" bgcolor="#CCCCCC">
<b>ตะกร้าสินค้า</span></td>
</tr>
<tr>
<td bgcolor="#EAEAEA">สินค้า</td>
<td align="center" bgcolor="#EAEAEA">ราคา</td>
<td align="center" bgcolor="#EAEAEA">จำนวน</td>
<td align="center" bgcolor="#EAEAEA">รวม(บาท)</td>
<td align="center" bgcolor="#EAEAEA">ลบ</td>
</tr>
<?php
$total=0;
if(!empty($_SESSION['cart']))
{
include("connectdb.php");
foreach($_SESSION['cart'] as $productid=>$qty)
{
$sqls="select * from producttb where productid = '$product_id'";
$db_query=mysqli_query($conn,$sqls);
$resultlv=mysqli_fetch_array($db_query);
$product_name = $rowp[productname];
$price_dis = $rowp[pricedis];
$price = $rowp[price];
$sum = $price * $qty;
$total += $sum;
echo "<tr>";
echo "<td width='334'>$product_name</td>";
echo "<td width='46' align='right'>" .number_format($price,2) . "</td>";
echo "<td width='57' align='right'>";
echo "<input type='text' name='amount[$productid]' value='$qty' size='2'/></td>";
echo "<td width='93' align='right'>".number_format($sum,2)."</td>";
//remove product
echo "<td width='46' align='center'><a href='cart.php?productid=$product_id&act=remove'>ลบ</a></td>";
echo "</tr>";
}
echo "<tr>";
echo "<td colspan='3' bgcolor='#CEE7FF' align='center'><b>ราคารวม</b></td>";
echo "<td align='right' bgcolor='#CEE7FF'>"."<b>".number_format($total,2)."</b>"."</td>";
echo "<td align='left' bgcolor='#CEE7FF'></td>";
echo "</tr>";
}
?>
<tr>
<td><a href="product.php">กลับหน้ารายการสินค้า</a></td>
<td colspan="4" align="right">
<input type="submit" name="button" id="button" value="ปรับปรุง" />
<input type="button" name="Submit2" value="สั่งซื้อ" onClick="window.location='confirm.php';" />
</td>
</tr>
</table>
</form>
</div>
<div align="center" class="row hidden-lg" style="padding-top:10px;">
<? echo "$fanpage"; ?>
</div>
<div align="center" class="row hidden-lg" style="padding-top:10px;">
<img src=images/transban.png class="img-responsive">
</div>
<div align="center" class="row hidden-lg" style="padding-top:10px;">
<a href=http://track.thailandpost.co.th/tracking/default.aspx target="_blank"><img src=images/emsban.png class="img-responsive" border="0"></a>
</div>
<div align="center" class="row hidden-lg" style="padding-top:10px;">
<a href=https://th.kerryexpress.com/th/track/ target="_blank"><img src=images/kerryban.png class="img-responsive" border="0"></a>
</div>
</div> <!-- ปิด Column ขวา-->
</div>
<div align="center" class="row" style="background-color:#000;padding:20px;"> <!-- OPEN FOOTER !-->
<? echo "<font color=#c9c5c5 size=2>$footertxt</font><br><font color=#ffffff size=2>$footerweb</font><br>$stat"; ?>
</div><!-- Close FOOTER !-->
</div>
<script src="myjs/jquery.min.js"></script>
<script src="myjs/bootstrap.min.js"></script>
<script src='myjs/jquery.touchSwipe.min.js'></script>
<script src="myjs/common.js"></script>
<script src="myjs/jquery-ui/jquery-ui.min.js"></script>
<script src="myjs/ie10-viewport-bug-workaround.js"></script>
<? require_once "cartpopup.php"; ?>
</body>
</html>
Tag : PHP, MySQL, HTML
|
|
|
|
|
|
Date :
2019-03-22 11:19:47 |
By :
because |
View :
591 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$sqls="select * from producttb where productid = '$product_id'";
$db_query=mysqli_query($conn,$sqls);
$resultlv=mysqli_fetch_array($db_query);
$product_name = $rowp[productname];
$price_dis = $rowp[pricedis];
$price = $rowp[price];
ตัวแปร $rowp มาจากไหนหรอครับ
มันต้องเป็นแบบนี้หรือป่าว
Code (PHP)
$sqls="select * from producttb where productid = '$product_id'";
$db_query=mysqli_query($conn,$sqls);
$resultlv=mysqli_fetch_array($db_query);
$product_name = $resultlv['productname'];
$price_dis = $resultlv['pricedis'];
$price = $resultlv['price'];
|
|
|
|
|
Date :
2019-03-22 16:11:40 |
By :
nobetaking |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|