|
|
|
ช่วยทีคับ อยากเขียน Code Selection box เพิ่มลงฐานข้อมูลครับ |
|
|
|
|
|
|
|
พอดีทำโปรเจคครับ อยากเพิ่มขอบเขตของระบบครับ ใครพอรู้แล้วทางนี้แนะด้วยนะครับ
จากรูปด้านบนครับ
คืออยากเพิ่มส่วนของ ให้ผู้ใช้ที่ต้องการจะสั่งซื้อสินค้า อยากให้มี option เลือก ขนาดของไซต์สินค้าเพิ่มครับ คือก่อนจะกด confirm ให้ผู้ใช้สามารถเลือกได้ว่าต้องการไซต์สินค้าขนาดเท่าไหร่ครับ จะเขียนโค๊ดเพิ่มเติมยังไงดีครับ
Code หน้า Confirm.php
Code (PHP)
<body>
<?
if($_SESSION['MemberId']== ""){
echo "<script language=\"javascript\">";
echo "alert('กรุณาล๊อคอินเข้าสู้ระบบ');";
echo "window.location='index.php';";
echo "</script>";
}else{
$Act=$_GET['Act'];
switch($Act){
case 'Confirm' : $CountName="Order";
$SelectCount=Select("ecom_count","WHERE CountName='".$CountName."'");
$Count=mysql_fetch_array($SelectCount);
$OrderId="Order-".substr("0000000".$Count['Count'],-5);
$Date=date("Y-m-d");
for($i=0;$i<=count($_SESSION['ProductId']);$i++){
$SelectProduct=Select("ecom_product","WHERE ProductId='".$_SESSION['ProductId'][$i]."'");
$Product=mysql_fetch_array($SelectProduct);
if($Product){
if($_SESSION['Quanlity'][$i]>$Product['Quanlity']){
$_SESSION['Quanlity'][$i]=$Product['Quanlity'];
}
$Price=$_SESSION['Quanlity'][$i]*$Product['Price'];
$Total=$Total+$Price;
$InsertOrderDetail=Insert("ecom_order_detail","OrderId,ProductId,Quanlity,Price","'".$OrderId."','".$_SESSION['ProductId'][$i]."','".$_SESSION['Quanlity'][$i]."','".$Price."'");
if($InsertOrderDetail != "" ){
$UpdateProduct=Update("ecom_product","Quanlity=Quanlity-'".$_SESSION['Quanlity'][$i]."' WHERE ProductId='".$_SESSION['ProductId'][$i]."'");
if($UpdateProduct != ""){
$_SESSION['ProductId'][$i]="";
$_SESSION['Quanlity'][$i]="";
}
}
}
}
$InsertOrder=Insert("ecom_order","MemberId,OrderId,Total,Date","'".$_SESSION['MemberId']."','".$OrderId."','".$Total."','".$Date."'");
if($InsertOrder != ""){
$UpdateCount=Update("ecom_count","Count=Count+1 WHERE CountName='".$CountName."'");
$To=$_SESSION['Email'];
$Subject="รายละเอียดใบสั่งซื้อ เลขที่ $OrderId";
$Message="<a href=\"www.deviltimes.com/detail_order.php?OrderId=$OrderId\"ท่านสามารถดูรายละเอียด Order ได้ที่นี่ Click";
mail($To,$Subject,$Message);
if($UpdateCount){
echo "<script language=\"javascript\">";
echo "alert('คุณได้ทำการสั่งซื้อเรียบร้อย');";
echo "window.location='howtopay.php';";
echo "</script>";
}
}
break;
}
$Select=Select("ecom_member","WHERE MemberId='".$_SESSION['MemberId']."'");
$Member=mysql_fetch_array($Select);
?>
<header id="header"><!--header-->
<? include('topmenu.php'); ?>
<div class="header-middle"><!--header-middle-->
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="logo pull-left">
<a href="index.php"><img src="images/home/logo.png" alt="" /></a>
</div>
</div>
<div class="col-sm-8">
<div class="shop-menu pull-right">
<ul class="nav navbar-nav">
<li><a href="#"><i class="fa fa-user"></i> Member</a><? include('login.php');?></li>
</ul>
</div>
</div>
</div>
</div>
</div><!--/header-middle-->
<div class="header-bottom"><!--header-bottom-->
<div class="container">
<div class="row">
<div class="col-sm-9">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="mainmenu pull-left">
<ul class="nav navbar-nav collapse navbar-collapse">
<li><a href="index.php">HOME</a></li>
<li><a href="category.php">CATEGORY</a></li>
<li class="dropdown"><a href="product.php?Act=Product">PRODUCT<i class="fa fa-angle-down"></i></a>
<ul role="menu" class="sub-menu">
<li><a href="product.php?Act=Product">ALL PRODUCT</a></li>
<li><a href="product.php?Act=New&New=Y">NEW PRODUCT</a></li>
<li><a href="product.php?Act=Promotion&Promotion=Y">PROMOTION PRODUCT</a></li>
</ul>
</li>
<li class="dropdown" ><a href="forum.php">FORUM<i class="fa fa-angle-down"></i></a>
<ul role="menu" class="sub-menu">
<li><a href="forum.php">FORUM</a></li>
<li><a href="howtopay.php">HOW TO PAY</a></li>
</ul>
</li>
<li><a href="contact.php">CONTACT</a></li>
<li><a href="cart.php">CART SHOPPING</a></li>
</ul>
</div>
</div>
<div class="col-sm-3">
<div class="search_box pull-right">
<form action="product.php" method="get">
<input type="hidden" name="Act" value="ProductSearch" />
<input type="text" name="ProductName" placeholder="Search"/>
</form>
</div>
</div>
</div>
</div>
</div><!--/header-bottom-->
</header><!--/header-->
<section>
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="left-sidebar">
<h2>Category</h2>
<div class="panel-group category-products" id="accordian"><!--category-productsr-->
<? include('menu_category.php'); ?>
</div><!--/category-products-->
<div class="brands_products"><!--shipping-->
<img src="images/home/ems.jpg" alt="" />
</div><!--/shipping-->
<div class="shipping text-center"><!--shipping-->
<img src="images/home/shipping.jpg" alt="" />
</div><!--/shipping-->
</div>
</div>
<div class="col-sm-9 padding-right">
<div class="features_items"><!--features_items-->
<h2 class="title text-center">CONFIRM CART</h2>
<div class="product-image-wrapper">
<div class="single-products">
<table width="100%" border="0" cellpadding="3">
<tr>
<td width="8"> </td>
<td colspan="7"> </td>
<td width="13"> </td>
</tr>
<tr>
<td width="8"> </td>
<td width="105"><div class="F-Object-Thai">รหัสสั่งซื้อเลขที่</div></td>
<td width="14">:</td>
<td width="181" class="MouseOverMenu"><div class="F-Center"><div class="F-Object-Eng">
<?
$CountName="Order";
$SelectCount=Select("ecom_count","WHERE CountName='".$CountName."'");
$Count=mysql_fetch_array($SelectCount);
echo "Order-".substr("0000000".$Count['Count'],-5);
?>
</div></div>
</td>
<td width="8"> </td>
<td width="112"><div class="F-Object-Thai">วันที่สั่งซื้อ</div></td>
<td width="9">:</td>
<td width="160"><div class="F-Object-Eng"><div class="F-Center"><? echo date('Y-m-d');?></div></div></td>
<td width="13"> </td>
</tr>
<tr>
<td width="8"> </td>
<td><div class="F-Object-Thai">ชื่อ-นามสกุล</div></td>
<td>:</td>
<td><div class="F-Object-Thai"><div class="F-Center">คุณ <? echo $Member['Name']." ".$Member['Surname'];?></div></div></td>
<td> </td>
<td><div class="F-Object-Thai">ชื่อเล่น</div></td>
<td>:</td>
<td><div class="F-Object-Thai"><div class="F-Center"><? echo $Member['Nickname']; ?></div></div></td>
<td> </td>
</tr>
<tr>
<td width="8"> </td>
<td><div class="F-Object-Thai">ที่อยู่ปัจจุบัน</div></td>
<td>:</td>
<td colspan="5"><div class="F-Object-Thai"><div class="F-Center"><? echo $Member['Address']." ".$Member['City']." ".$Member['Postcode'];?></div></div></td>
</tr>
<tr>
<td width="8"> </td>
<td><div class="F-Object-Thai">โทรศัพท์มือถือ</div></td>
<td>:</td>
<td><div class="F-Object-Thai"><div class="F-Center"><? echo $Member['MTel'];?></div></div></td>
<td> </td>
<td><div class="F-Object-Thai">โทรศัพท์บ้าน</div></td>
<td>:</td>
<td><div class="F-Object-Thai"><div class="F-Center"><? echo $Member['HTel']; ?></div></div></td>
<td> </td>
</tr>
</table>
</div>
</div>
</div><!--features_items-->
<div class="features_items"><!--features_items-->
<h2 class="title text-center">รายการสินค้าที่สั่งซื้อ</h2>
<div class="product-image-wrapper">
<div class="single-products">
<table width="100%" border="0" cellpadding="3">
<tr>
<td width="3"> </td>
<td colspan="6"> </td>
<td width="2"> </td>
</tr>
<tr>
<td width="3"> </td>
<td width="30"><div class="F-Object-Thai"><div class="F-Center">ลำดับ</div></div></td>
<td width="350"><div class="F-Object-Thai"><div class="F-Center">รายการสินค้า</div></div></td>
<td width="28"><div class="F-Object-Thai"><div class="F-Center">ราคา</div></div></td>
<td width="50"><div class="F-Object-Thai"><div class="F-Center">จำนวน</div></div></td>
<td width="48"><div class="F-Object-Thai"><div class="F-Center">ราคารวม</div></div></td>
<td width="68"><div class="F-Object-Thai"><div class="F-Center">หมายเหตุ</div></div></td>
<td width="2"> </td>
</tr>
<tr>
<td colspan="8"><img src="admin/image/line/line-full.png" width="100%" height="5" /></td>
</tr>
<? $No=0;
for($i=0;$i<=count($_SESSION['ProductId']);$i++){
$Select=Select("ecom_product","WHERE ProductId='".$_SESSION['ProductId'][$i]."'");
$Product=mysql_fetch_array($Select);
if($Product){
$No++;
?>
<tr id="Confirm<?=$No;?>" class="MouseOutMenu" onmouseover="MouseOverMenu('Confirm<?=$No;?>');" onmouseout="MouseOutMenu('Confirm<?=$No;?>');">
<td width="3"> </td>
<td><div class="F-Object-Eng"><div class="F-Center"><?=$No;?></div></div></td>
<td><div class="F-Object-Eng"><? echo iconv_substr($Product['ProductName'],0,50,"UTF-8"); ?></div></td>
<td><div class="F-Object-Eng"><div class="F-Center"><? echo number_format($Product['Price'],2,'.',','); ?></div></div></td>
<td><div class="F-Object-Eng"><div class="F-Center">
<?
if($_SESSION['Quanlity'][$i]>$Product['Quanlity']){
echo $_SESSION['Quanlity'][$i]=$Product['Quanlity'];
$Comment="<font color=\"#990000\">สินค้ามี <b>(".$Product['Quanlity'].")</b></font>";
}else{
echo $_SESSION['Quanlity'][$i];
$Comment="-";
}
?></div></div></td>
<td><div class="F-Object-Eng"><div class="F-Center">
<? echo number_format($Price=($Product['Price']*$_SESSION['Quanlity'][$i]),2,'.',','); $Total=$Total+$Price;?>
</div></div></td>
<td><div class="F-Object-Thai"><div class="F-Center">
<?
echo $Comment;
?>
</div></div></td>
<td> </td>
</tr>
<tr>
<td colspan="8"><img src="admin/image/line/line-full.png" width="100%" height="5" /></td>
</tr>
<?
}
}
?>
<tr>
<td width="3"> </td>
<td> </td>
<td width="292"> </td>
<td colspan="2"><div class="F-Object-Thai">ค่าจัดส่ง</div></td>
<td><div class="F-Object-Thai"><div class="F-Center">ฟรี</div></div></td>
<td><div class="F-Object-Thai"><div class="F-Center">บาท</div></div></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td width="292"> </td>
<td colspan="2"><div class="F-Object-Thai">ราคารวมทั้งสิ้น</div></td>
<td><div class="F-Object-Eng"><div class="F-Center"><font size="4" color="#990000"><? echo number_format($Total,2,'.',','); ?></font></div></div></td>
<td><div class="F-Object-Thai"><div class="F-Center">บาท</div></div></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="6"><div class="F-Center">
<input type="button" class="Btn" value="แก้ไข" onclick="window.location='cart.php';" />
<input type="button" class="Btn" value="ยืนยัน" onclick="window.location='?Act=Confirm';" />
</div></td>
<td> </td>
</tr>
</table>
</div>
</div>
</div><!--features_items-->
</div>
</div>
</div>
</section>
<? include('footer.php');?>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.scrollUp.min.js"></script>
<script src="js/price-range.js"></script>
<script src="js/jquery.prettyPhoto.js"></script>
<script src="js/main.js"></script>
</body>
</html>
<? } ?>
ส่วนของหน้า database ครับ
Tag : PHP, HTML/CSS, jQuery, CakePHP
|
|
|
|
|
|
Date :
2015-08-26 15:53:46 |
By :
naytee001 |
View :
1358 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จาก Code ไม่ทราบว่าติดปัญหาตรงไหนครับ
|
|
|
|
|
Date :
2015-08-27 09:04:25 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|