|
|
|
จะให้เเจ้งเตือน ว่าจำนวนสินค้าไม่พอตรงไหนอะค่ะ เเล้วเขียนยังไงอะค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?php require_once('Connections/com.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "Loginn.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "Loginn.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_com, $com);
$query_Recordset1 = "SELECT * FROM tb_product";
$Recordset1 = mysql_query($query_Recordset1, $com) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$colname_Recordset2 = "-1";
if (isset($_POST['Product01'])) {
$colname_Recordset2 = $_POST['Product01'];
}
mysql_select_db($database_com, $com);
$query_Recordset2 = sprintf("SELECT * FROM tb_product WHERE pro_name LIKE %s", GetSQLValueString("%" . $colname_Recordset2 . "%", "text"));
$Recordset2 = mysql_query($query_Recordset2, $com) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
$colname_Recordset3 = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_Recordset3 = $_SESSION['MM_Username'];
}
mysql_select_db($database_com, $com);
$query_Recordset3 = sprintf("SELECT * FROM customer WHERE username = %s", GetSQLValueString($colname_Recordset3, "text"));
$Recordset3 = mysql_query($query_Recordset3, $com) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);
mysql_select_db($database_com, $com);
$query_Recordset4 = "SELECT * FROM customer";
$Recordset4 = mysql_query($query_Recordset4, $com) or die(mysql_error());
$row_Recordset4 = mysql_fetch_assoc($Recordset4);
$totalRows_Recordset4 = mysql_num_rows($Recordset4);
?>
<body onload="MM_preloadImages('รูป/หน้าหลัก1.gif','รูป/รูปภาพ1.gif','รูป/สินค้า1.gif','รูป/วีดีโอ้2.gif','รูป/ติดต่อ1.gif')">
<table width="1330" border="1" align="center">
<tr>
<td colspan="5" bgcolor="#000000"><div align="center"><img src="รูป/รูป.jpg" width="1300" height="300" /></div></td>
</tr>
<tr>
<td height="47" colspan="4" bgcolor="#000000"><div align="center"><marquee>
ยินดีตอนรับ คุณ > > > > <?php echo $_SESSION['MM_Username']; ?>
< < < <
</marquee>
</div></td>
<td bgcolor="#000000"><div align="center"><a href="<?php echo $logoutAction ?>">ออกจากระบบ</a></div></td>
</tr>
<tr bgcolor="#000000">
<td width="261" height="79"><a href="Home.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','รูป/หน้าหลัก1.gif',1)"><img src="รูป/หน้าหลัก2.gif" name="Image7" width="250" height="75" border="0" id="Image7" /></a></td>
<td width="262"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image9','','รูป/สินค้า1.gif',1)"><img src="รูป/สินค้า2.gif" name="Image9" width="250" height="75" border="0" id="Image9" /></a></td>
<td width="262"><a href="Photo.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','รูป/รูปภาพ1.gif',1)"><img src="รูป/รูปภาพ2.gif" name="Image8" width="250" height="75" border="0" id="Image8" /></a></td>
<td width="264"><a href="VDO.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image10','','รูป/วีดีโอ้2.gif',1)"><img src="รูป/วีดีโอ้1.gif" name="Image10" width="250" height="75" border="0" id="Image10" /></a></td>
<td width="250"><a href="Contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','รูป/ติดต่อ1.gif',1)"><img src="รูป/ติดต่อ2.gif" name="Image6" width="250" height="75" border="0" id="Image6" /></a></td>
</tr>
<tr bgcolor="#000000">
<td rowspan="2" align="right" valign="top"><table width="266" border="1">
<tr>
<td width="256"><div align="center">
<table width="262" border="1">
<tr>
<td width="94">รหัสลูกค้า</td>
<td width="152"><? echo str_pad($row_Recordset4['member_id'],5,"TEE ",STR_PAD_LEFT); ?></td>
</tr>
<tr>
<td>ชื่อ</td>
<td><?php echo $row_Recordset4['name']; ?></td>
</tr>
<tr>
<td>นามสกุล</td>
<td><?php echo $row_Recordset4['lastname']; ?></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><a href="showp.php"><img src="รูป/ตะกร้า.gif" width="268" height="70" /></a></td>
</tr>
</table> <p> </p></td>
<td height="104" colspan="3" valign="top" bgcolor="#000000"><img src="รูป/product00.jpg" width="800" height="100" /></td>
<td rowspan="2" valign="top" bgcolor="#000000"><img src="รูป/images/ลดราคา...gif" width="250" height="510" hspace="0" vspace="0" align="top" /></td>
</tr>
<tr bgcolor="#000000">
<td colspan="3" align="center" valign="top" bgcolor="#000000"><form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="1">
<tr>
<th>
Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>">
<input type="submit" value="Search"></th>
</tr>
</table>
</form>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("com");
mysql_query("SET NAMES UTF8");
// Search By Name or Email
$strSQL = "SELECT * FROM tb_product WHERE 1 ";
if($_POST["ddlprotype_id"] != "")
{
$strSQL .= " AND (protype_id = '".$_POST["ddlprotype_id"]."') ";
}
if($_POST["txtKeyword"] != "")
{
$strSQL .= " AND (pro_name LIKE '%".$_POST["txtKeyword"]."%' or protype_id LIKE '%".$_POST["txtKeyword"]."%' ) ";
}
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="800" border="1">
<tr align="center">
<th width="56"> <div align="center">รูปภาพ</div></th>
<th width="20"><div align="center">รหัสสินค้า</div></th>
<th width="100"> <div align="center">ชื่อสินค้า </div></th>
<th width="150"> <div align="center">ประเภทสินค้า </div></th>
<th width="300"> <div align="center">รายละเอียด </div></th>
<th width="50"> <div align="center">ราคา </div></th>
<th width="20"> <div align="center">จำนวน </div></th>
<th colspan="2">Cart</th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr align="center">
<form action="orderp.php" method="post">
<td><div align="center"><img src="img-products/<?php echo $objResult["pro_image"];?>"></div></td>
<td><?=$objResult["pro_id"];?></td>
<td><?=$objResult["pro_name"];?></td>
<td><?=$objResult["protype_id"];?></td>
<td><div align="center"><?=$objResult["pro_detail"];?></div></td>
<td><?=$objResult["pro_price"];?></td>
<td><?=$objResult["pro_number"];?></td>
<td width="100"><input type="hidden" name="txtpro_id" value="<?php echo $objResult["pro_id"];?>" size="2" />
<input type="text" name="txtQty" value="1" size="3" /></td>
<td width="34"><input name="add" type="submit" id="add" value="เพิ่ม" /></td>
</form>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?> </td>
</tr>
<tr>
<td height="300" colspan="5"><img src="รูป/images/ด้านล้างใหม่.gif" width="1300" height="300" /></td>
</tr>
</table><html>
<head>
</body>
</html>
</body>
</html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
mysql_free_result($Recordset3);
mysql_free_result($Recordset4);
?>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2017-01-29 00:12:48 2017-01-29 00:27:10
|
|
|
|
|
Date :
2017-01-29 00:09:06 |
By :
jeedjrad |
View :
1083 |
Reply :
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยที่นะค๊ะะะะะะะะะะะะะะ > <
|
|
|
|
|
Date :
2017-01-29 00:11:02 |
By :
เจ้าหญิง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ควรจะแก้ที่ไฟล์ orderp.php นะครับ
|
|
|
|
|
Date :
2017-01-29 00:48:47 |
By :
tomrambo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตรงไหนนะคะ
Code (PHP)
<?php
ob_start();
session_start();
if(!isset($_SESSION["intLine"]))
{
if(isset($_POST["txtpro_id"]))
{
$_SESSION["intLine"] = 0;
$_SESSION["strpro_id"][0] = $_POST["txtpro_id"];
$_SESSION["strQty"][0] = $_POST["txtQty"];
header("location:showp.php");
}
}
else
{
$key = array_search($_POST["txtpro_id"], $_SESSION["strpro_id"]);
if((string)$key != "")
{
$_SESSION["strQty"][$key] = $_SESSION["strQty"][$key] + $_POST["txtQty"];
}
else
{
$_SESSION["intLine"] = $_SESSION["intLine"] + 1;
$intNewLine = $_SESSION["intLine"];
$_SESSION["strpro_id"][$intNewLine] = $_POST["txtpro_id"];
$_SESSION["strQty"][$intNewLine] = $_POST["txtQty"];
}
header("location:showp.php");
}
?>
<?php /* This code download from www.ThaiCreate.Com */ ?>
|
ประวัติการแก้ไข 2017-01-29 01:07:16
|
|
|
|
Date :
2017-01-29 00:54:49 |
By :
เจ้าหญิง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- ชื่อไฟล์โค้ดอันแรกชื่อไฟล์อะไรครับ
- ชื่อฟิลด์เก็บจำนวนสินค้าใน database ชื่ออะไรครับ
|
|
|
|
|
Date :
2017-01-29 11:14:31 |
By :
tomrambo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไฟล์ product.php
<?php require_once('Connections/com.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "Loginn.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "Loginn.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_com, $com);
$query_Recordset1 = "SELECT * FROM tb_product";
$Recordset1 = mysql_query($query_Recordset1, $com) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$colname_Recordset2 = "-1";
if (isset($_POST['Product01'])) {
$colname_Recordset2 = $_POST['Product01'];
}
mysql_select_db($database_com, $com);
$query_Recordset2 = sprintf("SELECT * FROM tb_product WHERE pro_name LIKE %s", GetSQLValueString("%" . $colname_Recordset2 . "%", "text"));
$Recordset2 = mysql_query($query_Recordset2, $com) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
$colname_Recordset3 = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_Recordset3 = $_SESSION['MM_Username'];
}
mysql_select_db($database_com, $com);
$query_Recordset3 = sprintf("SELECT * FROM customer WHERE username = %s", GetSQLValueString($colname_Recordset3, "text"));
$Recordset3 = mysql_query($query_Recordset3, $com) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);
mysql_select_db($database_com, $com);
$query_Recordset4 = "SELECT * FROM customer";
$Recordset4 = mysql_query($query_Recordset4, $com) or die(mysql_error());
$row_Recordset4 = mysql_fetch_assoc($Recordset4);
$totalRows_Recordset4 = mysql_num_rows($Recordset4);
?>
<!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=utf-8" />
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
function uzXmlHttp(){
var xmlhttp = false;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlhttp = false;
}
}
if(!xmlhttp && document.createElement){
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function checkQTY(msg, p_id){
var p_qty = document.getElementById('txtQty').value;
var xhr = uzXmlHttp();
xhr.open ("POST","checkQTY.php");
xhr.onreadystatechange = responseXHR;
xhr.setRequestHeader ("Content-type", "application/x-www-form-urlencoded");
xhr.send("product_id="+p_id+"product_qty="+p_qty);
function responseXHR()
{
if ( xhr.readyState == 4 )
{
if ( xhr.status == 200 )
{
if(xhr.responseText == 1){
document.form_1.submit();
}else{
alert(msg);
}
}
}
}
}
</script>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:1065px;
top:405px;
width:250px;
height:510px;
z-index:1;
}
#apDiv2 {
position:absolute;
left:19px;
top:921px;
width:1298px;
height:150px;
z-index:1;
}
#apDiv3 {
position:absolute;
left:538px;
top:970px;
width:846px;
height:214px;
z-index:1;
}
body {
background-color: #CCC;
}
#apDiv4 {
position:absolute;
left:17px;
top:406px;
width:255px;
height:325px;
z-index:1;
}
-->
</style>
<link href="login.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body,td,th {
color: #FFF;
font-size: 24px;
font-family: FontNongnam;
}
#form1 {
font-family: PL-EDIT;
}
body p {
font-family: Verdana, Geneva, sans-serif;
}
body p {
font-family: PL-EDIT;
}
body p {
font-family: FontNongnam;
}
body table tr td div marquee {
font-size: 36px;
}
body table tr td div a {
font-size: 36px;
}
td {
color: #000;
}
td {
color: #FFF;
}
-->
</style></head>
<body onload="MM_preloadImages('รูป/หน้าหลัก1.gif','รูป/รูปภาพ1.gif','รูป/สินค้า1.gif','รูป/วีดีโอ้2.gif','รูป/ติดต่อ1.gif')">
<table width="1330" border="1" align="center">
<tr>
<td colspan="5" bgcolor="#000000"><div align="center"><img src="รูป/รูป.jpg" width="1300" height="300" /></div></td>
</tr>
<tr>
<td height="47" colspan="4" bgcolor="#000000"><div align="center"><marquee>
ยินดีตอนรับ คุณ > > > > <?php echo $_SESSION['MM_Username']; ?>
< < < <
</marquee>
</div></td>
<td bgcolor="#000000"><div align="center"><a href="<?php echo $logoutAction ?>">ออกจากระบบ</a></div></td>
</tr>
<tr bgcolor="#000000">
<td width="261" height="79"><a href="Home.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','รูป/หน้าหลัก1.gif',1)"><img src="รูป/หน้าหลัก2.gif" name="Image7" width="250" height="75" border="0" id="Image7" /></a></td>
<td width="262"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image9','','รูป/สินค้า1.gif',1)"><img src="รูป/สินค้า2.gif" name="Image9" width="250" height="75" border="0" id="Image9" /></a></td>
<td width="262"><a href="Photo.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','รูป/รูปภาพ1.gif',1)"><img src="รูป/รูปภาพ2.gif" name="Image8" width="250" height="75" border="0" id="Image8" /></a></td>
<td width="264"><a href="VDO.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image10','','รูป/วีดีโอ้2.gif',1)"><img src="รูป/วีดีโอ้1.gif" name="Image10" width="250" height="75" border="0" id="Image10" /></a></td>
<td width="250"><a href="Contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','รูป/ติดต่อ1.gif',1)"><img src="รูป/ติดต่อ2.gif" name="Image6" width="250" height="75" border="0" id="Image6" /></a></td>
</tr>
<tr bgcolor="#000000">
<td rowspan="2" align="right" valign="top"><table width="266" border="1">
<tr>
<td width="256"><div align="center">
<table width="262" border="1">
<tr>
<td width="94">รหัสลูกค้า</td>
<td width="152"><? echo str_pad($row_Recordset4['member_id'],5,"TEE ",STR_PAD_LEFT); ?></td>
</tr>
<tr>
<td>ชื่อ</td>
<td><?php echo $row_Recordset4['name']; ?></td>
</tr>
<tr>
<td>นามสกุล</td>
<td><?php echo $row_Recordset4['lastname']; ?></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><a href="showp.php"><img src="รูป/ตะกร้า.gif" width="268" height="70" /></a></td>
</tr>
</table> <p> </p></td>
<td height="104" colspan="3" valign="top" bgcolor="#000000"><img src="รูป/product00.jpg" width="800" height="100" /></td>
<td rowspan="2" valign="top" bgcolor="#000000"><img src="รูป/images/ลดราคา...gif" width="250" height="510" hspace="0" vspace="0" align="top" /></td>
</tr>
<tr bgcolor="#000000">
<td colspan="3" align="center" valign="top" bgcolor="#000000"><form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="1">
<tr>
<th>
Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>">
<input type="submit" value="Search"></th>
</tr>
</table>
</form>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("com");
mysql_query("SET NAMES UTF8");
// Search By Name or Email
$strSQL = "SELECT * FROM tb_product WHERE 1 ";
if($_POST["ddlprotype_id"] != "")
{
$strSQL .= " AND (protype_id = '".$_POST["ddlprotype_id"]."') ";
}
if($_POST["txtKeyword"] != "")
{
$strSQL .= " AND (pro_name LIKE '%".$_POST["txtKeyword"]."%' or protype_id LIKE '%".$_POST["txtKeyword"]."%' ) ";
}
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="800" border="1">
<tr align="center">
<th width="56"> <div align="center">รูปภาพ</div></th>
<th width="20"><div align="center">รหัสสินค้า</div></th>
<th width="100"> <div align="center">ชื่อสินค้า </div></th>
<th width="150"> <div align="center">ประเภทสินค้า </div></th>
<th width="300"> <div align="center">รายละเอียด </div></th>
<th width="50"> <div align="center">ราคา </div></th>
<th width="20"> <div align="center">จำนวน </div></th>
<th colspan="2">Cart</th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr align="center">
<form name="form_1" action="orderp.php" method="post">
<td><div align="center"><img src="img-products/<?php echo $objResult["pro_image"];?>"></div></td>
<td><?=$objResult["pro_id"];?></td>
<td><?=$objResult["pro_name"];?></td>
<td><?=$objResult["protype_id"];?></td>
<td><div align="center"><?=$objResult["pro_detail"];?></div></td>
<td><?=$objResult["pro_price"];?></td>
<td><?=$objResult["pro_number"];?></td>
<td width="100"><input type="hidden" name="txtpro_id" value="<?php echo $objResult["pro_id"];?>" size="2" />
<input type="text" name="txtQty" id="txtQty" value="1" size="3" /></td>
<td width="34"><input name="add_button" type="button" value="เพิ่ม" onclick="checkQTY('ขออภัย! จำนวนสินค้ามีไม่เพียงพอ', '<?php echo $objResult['pro_id'] ?>')" /></td>
</form>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?> </td>
</tr>
<tr>
<td height="300" colspan="5"><img src="รูป/images/ด้านล้างใหม่.gif" width="1300" height="300" /></td>
</tr>
</table><html>
<head>
</body>
</html>
</body>
</html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
mysql_free_result($Recordset3);
mysql_free_result($Recordset4);
?>
สร้างไฟล์ชื่อ checkQTY.php ขึ้นมาแล้วใส่โค้ดด้านล่างลงไปครับ
<?php
require('Connections/com.php');
mysql_select_db($database_com, $com);
$sql = mysql_query("SELECT pro_number FROM tb_product WHERE pro_id = '".$_POST['product_id']."'") or die("Database Error!");
$result = mysql_fetch_assoc($sql);
if(($result['pro_number'] - $_POST['product_qty']) >= 0){
echo 1;
}else{
echo 0;
}
?>
|
ประวัติการแก้ไข 2017-01-29 22:45:53 2017-01-29 22:46:53
|
|
|
|
Date :
2017-01-29 22:45:08 |
By :
tomrambo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณนะคะ เพิ่งไปต่างจังหวะเพิ่งกลับคะ จะลองนะคะ
|
|
|
|
|
Date :
2017-01-30 20:38:38 |
By :
เเพรว |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ดูว่ามัน Alert แจ้งว่าอย่างไรครับ
<?php require_once('Connections/com.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "Loginn.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "Loginn.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_com, $com);
$query_Recordset1 = "SELECT * FROM tb_product";
$Recordset1 = mysql_query($query_Recordset1, $com) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$colname_Recordset2 = "-1";
if (isset($_POST['Product01'])) {
$colname_Recordset2 = $_POST['Product01'];
}
mysql_select_db($database_com, $com);
$query_Recordset2 = sprintf("SELECT * FROM tb_product WHERE pro_name LIKE %s", GetSQLValueString("%" . $colname_Recordset2 . "%", "text"));
$Recordset2 = mysql_query($query_Recordset2, $com) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
$colname_Recordset3 = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_Recordset3 = $_SESSION['MM_Username'];
}
mysql_select_db($database_com, $com);
$query_Recordset3 = sprintf("SELECT * FROM customer WHERE username = %s", GetSQLValueString($colname_Recordset3, "text"));
$Recordset3 = mysql_query($query_Recordset3, $com) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);
mysql_select_db($database_com, $com);
$query_Recordset4 = "SELECT * FROM customer";
$Recordset4 = mysql_query($query_Recordset4, $com) or die(mysql_error());
$row_Recordset4 = mysql_fetch_assoc($Recordset4);
$totalRows_Recordset4 = mysql_num_rows($Recordset4);
?>
<!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=utf-8" />
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
function uzXmlHttp(){
var xmlhttp = false;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlhttp = false;
}
}
if(!xmlhttp && document.createElement){
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function checkQTY(msg, p_id){
var p_qty = document.getElementById('txtQty').value;
var xhr = uzXmlHttp();
xhr.open ("POST","checkQTY.php");
xhr.onreadystatechange = responseXHR;
xhr.setRequestHeader ("Content-type", "application/x-www-form-urlencoded");
xhr.send("product_id="+p_id+"product_qty="+p_qty);
function responseXHR()
{
if ( xhr.readyState == 4 )
{
if ( xhr.status == 200 )
{
alert(xhr.responseText);
}
}
}
}
</script>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:1065px;
top:405px;
width:250px;
height:510px;
z-index:1;
}
#apDiv2 {
position:absolute;
left:19px;
top:921px;
width:1298px;
height:150px;
z-index:1;
}
#apDiv3 {
position:absolute;
left:538px;
top:970px;
width:846px;
height:214px;
z-index:1;
}
body {
background-color: #CCC;
}
#apDiv4 {
position:absolute;
left:17px;
top:406px;
width:255px;
height:325px;
z-index:1;
}
-->
</style>
<link href="login.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body,td,th {
color: #FFF;
font-size: 24px;
font-family: FontNongnam;
}
#form1 {
font-family: PL-EDIT;
}
body p {
font-family: Verdana, Geneva, sans-serif;
}
body p {
font-family: PL-EDIT;
}
body p {
font-family: FontNongnam;
}
body table tr td div marquee {
font-size: 36px;
}
body table tr td div a {
font-size: 36px;
}
td {
color: #000;
}
td {
color: #FFF;
}
-->
</style></head>
<body onload="MM_preloadImages('รูป/หน้าหลัก1.gif','รูป/รูปภาพ1.gif','รูป/สินค้า1.gif','รูป/วีดีโอ้2.gif','รูป/ติดต่อ1.gif')">
<table width="1330" border="1" align="center">
<tr>
<td colspan="5" bgcolor="#000000"><div align="center"><img src="รูป/รูป.jpg" width="1300" height="300" /></div></td>
</tr>
<tr>
<td height="47" colspan="4" bgcolor="#000000"><div align="center"><marquee>
ยินดีตอนรับ คุณ > > > > <?php echo $_SESSION['MM_Username']; ?>
< < < <
</marquee>
</div></td>
<td bgcolor="#000000"><div align="center"><a href="<?php echo $logoutAction ?>">ออกจากระบบ</a></div></td>
</tr>
<tr bgcolor="#000000">
<td width="261" height="79"><a href="Home.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','รูป/หน้าหลัก1.gif',1)"><img src="รูป/หน้าหลัก2.gif" name="Image7" width="250" height="75" border="0" id="Image7" /></a></td>
<td width="262"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image9','','รูป/สินค้า1.gif',1)"><img src="รูป/สินค้า2.gif" name="Image9" width="250" height="75" border="0" id="Image9" /></a></td>
<td width="262"><a href="Photo.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','รูป/รูปภาพ1.gif',1)"><img src="รูป/รูปภาพ2.gif" name="Image8" width="250" height="75" border="0" id="Image8" /></a></td>
<td width="264"><a href="VDO.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image10','','รูป/วีดีโอ้2.gif',1)"><img src="รูป/วีดีโอ้1.gif" name="Image10" width="250" height="75" border="0" id="Image10" /></a></td>
<td width="250"><a href="Contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','รูป/ติดต่อ1.gif',1)"><img src="รูป/ติดต่อ2.gif" name="Image6" width="250" height="75" border="0" id="Image6" /></a></td>
</tr>
<tr bgcolor="#000000">
<td rowspan="2" align="right" valign="top"><table width="266" border="1">
<tr>
<td width="256"><div align="center">
<table width="262" border="1">
<tr>
<td width="94">รหัสลูกค้า</td>
<td width="152"><? echo str_pad($row_Recordset4['member_id'],5,"TEE ",STR_PAD_LEFT); ?></td>
</tr>
<tr>
<td>ชื่อ</td>
<td><?php echo $row_Recordset4['name']; ?></td>
</tr>
<tr>
<td>นามสกุล</td>
<td><?php echo $row_Recordset4['lastname']; ?></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><a href="showp.php"><img src="รูป/ตะกร้า.gif" width="268" height="70" /></a></td>
</tr>
</table> <p> </p></td>
<td height="104" colspan="3" valign="top" bgcolor="#000000"><img src="รูป/product00.jpg" width="800" height="100" /></td>
<td rowspan="2" valign="top" bgcolor="#000000"><img src="รูป/images/ลดราคา...gif" width="250" height="510" hspace="0" vspace="0" align="top" /></td>
</tr>
<tr bgcolor="#000000">
<td colspan="3" align="center" valign="top" bgcolor="#000000"><form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="1">
<tr>
<th>
Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>">
<input type="submit" value="Search"></th>
</tr>
</table>
</form>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("com");
mysql_query("SET NAMES UTF8");
// Search By Name or Email
$strSQL = "SELECT * FROM tb_product WHERE 1 ";
if($_POST["ddlprotype_id"] != "")
{
$strSQL .= " AND (protype_id = '".$_POST["ddlprotype_id"]."') ";
}
if($_POST["txtKeyword"] != "")
{
$strSQL .= " AND (pro_name LIKE '%".$_POST["txtKeyword"]."%' or protype_id LIKE '%".$_POST["txtKeyword"]."%' ) ";
}
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="800" border="1">
<tr align="center">
<th width="56"> <div align="center">รูปภาพ</div></th>
<th width="20"><div align="center">รหัสสินค้า</div></th>
<th width="100"> <div align="center">ชื่อสินค้า </div></th>
<th width="150"> <div align="center">ประเภทสินค้า </div></th>
<th width="300"> <div align="center">รายละเอียด </div></th>
<th width="50"> <div align="center">ราคา </div></th>
<th width="20"> <div align="center">จำนวน </div></th>
<th colspan="2">Cart</th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr align="center">
<form name="form_1" action="orderp.php" method="post">
<td><div align="center"><img src="img-products/<?php echo $objResult["pro_image"];?>"></div></td>
<td><?=$objResult["pro_id"];?></td>
<td><?=$objResult["pro_name"];?></td>
<td><?=$objResult["protype_id"];?></td>
<td><div align="center"><?=$objResult["pro_detail"];?></div></td>
<td><?=$objResult["pro_price"];?></td>
<td><?=$objResult["pro_number"];?></td>
<td width="100"><input type="hidden" name="txtpro_id" value="<?php echo $objResult["pro_id"];?>" size="2" />
<input type="text" name="txtQty" id="txtQty" value="1" size="3" /></td>
<td width="34"><input name="add_button" type="button" value="เพิ่ม" onclick="checkQTY('ขออภัย! จำนวนสินค้ามีไม่เพียงพอ', '<?php echo $objResult['pro_id'] ?>')" /></td>
</form>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?> </td>
</tr>
<tr>
<td height="300" colspan="5"><img src="รูป/images/ด้านล้างใหม่.gif" width="1300" height="300" /></td>
</tr>
</table><html>
<head>
</body>
</html>
</body>
</html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
mysql_free_result($Recordset3);
mysql_free_result($Recordset4);
?>
|
ประวัติการแก้ไข 2017-01-30 21:03:45
|
|
|
|
Date :
2017-01-30 21:02:55 |
By :
tomrambo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วลองใส่เกินจำนวนสินค้าที่มีในสต๊อกมัน Alert ว่าไรหรอครับ
|
|
|
|
|
Date :
2017-01-30 21:22:56 |
By :
tomrambo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เช็คข้อความส่วนตัวด้วยครับ
|
|
|
|
|
Date :
2017-01-30 21:29:49 |
By :
tomrambo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จขกท. ลองคิดเหตุผลง่ายๆครับ แล้วนำไปใช้สร้างเงื่อนไขในระบบ ตะกร้าสินค้าของเรา
สมมุติเรามีเงิน 10 บาท ต้องการซื้อของ โดยจำลองสินค้า ดังนี้
Code (PHP)
$money = 10; //เงินที่เรามี
//สินค้า
$apple = 20;
$mango = 10;
$orange = 5;
$cart = ""; //ตะกร้าสินค้า
$buy_product = ""; //สินค้าที่เลือก และอยากซื้อ
if($buy_product == "apple"){
$money-$apple; //= -10
echo "ซื้อไม่ได้ เงินไม่พอ";
}else if($buy_product == "mango "){
$money-$apple; //= 0
echo "ซื้อได้ เงินพอ";
}else if($buy_product == "orange"){
$money-$orange ; //= 5
echo "ซื้อได้ เงินเหลือ";
}
|
|
|
|
|
Date :
2017-01-31 04:40:53 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|