|
 |
|
มันไม่ยอททำเงื่อนไขช่วยหาจุดผิดให้หน่อยครับ กำลังทำโปรเจคอยู่เลยครับ |
|
 |
|
|
 |
 |
|
if(count($sess_id) == 0){
print"ยังไม่มีสินค้าอยู่ในตะกร้า<br>";
}else{
$sess_id เอามาจากไหนครับ เป็น array หรือเปล่า
คำสั่ง count() ใช้กับ array ครับ
strlen() ใช้กับ String ครับ
ปล. test คำสั่ง count()
Code (PHP)
<?php
$a=null; $b='abcd'; $c=array('a', 'b', 'c');
echo count($a), ',', count($b), ',', count($c);
?>
0,1,3
|
ประวัติการแก้ไข 2014-10-12 12:33:06
 |
 |
 |
 |
Date :
2014-10-12 12:10:49 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับ
|
 |
 |
 |
 |
Date :
2014-10-12 12:36:15 |
By :
taozt |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันมาจากอันนี้อ่ะครับ
Code (PHP)
<?
session_start();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<?
include"connect.php";
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$address = $_POST["address"];
$total = $_POST["total_order"];
if($name == ""){
echo"<h3 align=center> error:กรุณากรอกชื่อ</h3>";
exit();
}else if($address == ""){
echo"<h3 align=center> error:กรุณากรอกที่อยู่</h3>";
exit();
}
$date_now = date("Y-M-d");
$sql1 = "insert into orders (order_id,order_name,order_address,order_email,order_phone,order_total,order_date) value (null,'$name','$address','$email','$phone','$total','$date_now')";
mysql_query($sql1,$conn);
$sql2 = "select max(order_id) from orders";
$ex2 = mysql_db_query($dbname,$sql2);
$row = mysql_fetch_row($ex2);
for($i=0; $i<count($sess_id); $i++) {
$sql3 = "insert into order_detail value ('$row[0]','$sess_id[$i]','$sess_name[$i]','$sess_price[$i]','$sess_num[$i]')";
mysql_query($sql3,$conn);
}
session_start();
session_unregister("sess_id");
session_unregister("sess_name");
session_unregister("sess_price");
session_unregister("sess_num");
echo "<h3 align=center>ทำการบันทึกใบสั่งซื้อเรียบร้อยแล้ว</h3>";
echo"<h3 align=center><a href=index.php>กลับหน้าหลัก</a></h3>";
/*unset($_SESSION['sess_id']);
unset($_SESSION['sess_name']);
unset($_SESSION['sess_price']);
unset($_SESSION['sess_num']); // set in fun_users.php
*/
mysql_close($conn);
?>
<body>
</body>
</html>
|
 |
 |
 |
 |
Date :
2014-10-12 12:51:04 |
By :
taozt |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับสำหรับความรู้ใหม่ๆด้วยครับ
|
 |
 |
 |
 |
Date :
2014-10-12 14:36:43 |
By :
taozt |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|