พบกับบทความเกี่ยวกับคอมพิวเตอร์และ programming ได้ที่ http://articles.modoeye.com
PHP development / กรอกข้อมูลในฟอร์มแล้วไม่มีข้อมูลในDB
BaRaMos
BaRaMos
Wed 16 Jul 2008 10:59:54

กรอกข้อมูลในฟอร์มแล้วไม่มีข้อมูลใน DB ค่ะ ไม่ทราบว่าโค้ดผิดตรงไหนหรือเปล่า รบกวนช่วยดูให้หน่อยนะคะ ติดมาอาทิตย์นึงแล้ว Y_Y

ขอบคุณค่ะ

ระบบจองห้องประชุม  ใช้ phpmyadmin

<?
include "../lib/connect_db.php";
/*if (!isset($area_size)) {
 $area_size = "";
}*/
$project_name = addslashes($project_name);
$project_time = addslashes($project_time);
$description = addslashes($description);
$owner = addslashes($owner);
$contact_no = addslashes($contact_no);
$request_date  = date("Y-m-d H:i:s");
$day = date("d",strtotime($project_date));
$month = date("m",strtotime($project_date));
$year = date("Y",strtotime($project_date));

$date_txt = date ("D, j F Y", strtotime ($project_date) );
if ($picture != "") {
 if ($picture_size > 2097152) {
  echo "<script>alert('File size must be less than 2M.')";
  echo "window.location.history.back();</script>";
 }else{
  $n = 0;
  while (file_exists("../upload/$picture_name")) {
   $n++;
   $picture_name = $n."_".$picture_name;
  }
  copy($picture,"../upload/".$picture_name);
  //$psize = filesize($picture_name);
  //$bpicture = addslashes(fread(fopen($picture_name,"r"),$psize));
  $sql = "insert into booking (id,room_code,project_name,project_date,project_time,description,owner,department,contact_no,email,request_date,picture_type,picture_name) values('','$room','$project_name','$project_date','$project_time','$description','$owner','$department','$contact_no','$email','$request_date','$picture_type','$picture_name')";
  mysql_query($sql);
  
  // for many days
  if (($finish_date != "") &&($project_date < $finish_date))  {   
   $nextday  = date("Y-m-d",mktime (0,0,0,$month,++$day,$year));
   while($nextday <= $finish_date ){
    $project_date = $nextday;
    $sql = "insert into booking (id,room_code,project_name,project_date,project_time,description,owner,department,contact_no,email,request_date,picture_type,picture_name) values('','$room','$project_name','$project_date','$project_time','$description','$owner','$department','$contact_no','$email','$request_date','$picture_type','$picture_name')";
    mysql_query($sql);
    $nextday  = date("Y-m-d",mktime (0,0,0,$month,++$day,$year));
   }
  }  
  // end for many days
 }
} else{
 $sql = "insert into booking (id,room_code,project_name,project_date,project_time,description,owner,department,contact_no,email,request_date) values('','$room','$project_name','$project_date','$project_time','$description','$owner','$department','$contact_no','$email','$request_date')";
 mysql_query($sql);
 //echo $sql;
 // for many days
 if (($finish_date != "") &&($project_date < $finish_date)) {   
  $nextday  = date("Y-m-d",mktime (0,0,0,$month,++$day,$year));
  while($nextday <= $finish_date ){
   $project_date = $nextday;
   $sql = "insert into booking (id,room_code,project_name,project_date,project_time,description,owner,department,contact_no,email,request_date) values('','$room','$project_name','$project_date','$project_time','$description','$owner','$department','$contact_no','$email','$request_date')";
   //echo $sql;
   mysql_query($sql);
   $nextday  = date("Y-m-d",mktime (0,0,0,$month,++$day,$year));
  }
 }  
 // end for many days
}


// Find room name
$bsql = "select room_name from room where room_code = '$room'";
$brs = mysql_query($bsql);
$brow = mysql_fetch_row($brs);
$room_name = $brow[0];

// End find room name

//$to = "mail Address"; // Admin's E-mail Address
$to = "mail Address"; // Admin's E-mail Address

$subject = "New Reservation";
$header = "From: $email\r\n";
$header .= "Content-Type: text/html; charset=windows-874\n";
$body = "<link href='http://ktc-mind/boardroom2/css/fontstyle.css' rel='stylesheet' type='text/css'>";
$body .= "<p class=tahoma12>There is a new reservation. Please click link as below.<br>";
$body .= "<a href='http://ktc-mind/boardroom2/admin/viewlist.php?view=A&u=admin&p=1234'>Boardroom Booking Management</a>";
//$body .= "<span class='tahoma11'><br><br>Room : $room_name";
//$body .= "<br>Date : $date_txt";
//$body .= "<br>Time : $project_time</span>";
$message = wordwrap($body,72);
  
if (!mail($to,$subject, $message, $header) ) {
 $mail_error = "Unable to send mail";
 echo  "<script>alert('".$mail_error."');</script>";
}

echo "<script>alert('Your reservation has been sent.');";
echo "window.location.href='../browse/index.php?month=$month&year=$year&room=$room';</script>";
mysql_close();

?>

webmaster
webmaster
Sat 19 Jul 2008 00:41:28
echo คำสั่งออกมาแล้วเอาไปลอง query ใน phpMyAdmin ดูก่อนครับ
BaRaMos
BaRaMos
Mon 21 Jul 2008 10:26:42

ขอบคุณค่ะ แสดงผลได้แล้วค่ะ

แต่ว่ามีปัญหาใหม่มารบกวนอีกแล้วค่ะ แหะๆๆ

ตัวอย่างค่ะ ระบบจองห้องประชุม

ที่ row Time

1.สามารถกรอกข้อมูลเวลาการจองลงใน textbox ได้ เช่น จองเวลา 15.00-17.00

2.แต่ถ้าผู้ใช้ต้องการจองแบบทั้งวัน คือ 8.00-17.00 โดยที่ไม่ต้องพิมพ์ แต่ใช้กดปุ่มเลือก จองทั้งวัน แล้วให้ค่า 8.00-17.00 แสดงบน textbox เลย

ตามตัวอย่างต้องเขียน code ประมาณไหนคะ

ขอบคุณอีกครั้งค่ะ

webmaster
webmaster
Mon 21 Jul 2008 22:22:09
ใช้ javascript สั่งให้เขียนไปที่ input นั้นๆครับ
BaRaMos
BaRaMos
Wed 30 Jul 2008 08:04:32

ตอนนี้ทำได้แล้วค่ะ นั่งงงอยู่นานเลยกว่าจะได้

ถ้ามีอะไรสงสัยอีก เดี๋ยวจะเข้ามาถามอีกค่ะ อิอิ

ขอบคุณมากๆค่ะ (^_' )v

BaRaMos
BaRaMos
Wed 6 Aug 2008 16:05:33

คุณ webmaster คะ ถ้าต้องการให้สามารถโชว์สถานะของห้องประชุมแต่ละห้องได้ คือห้องที่มีการใช้อยู่ ให้เป็นสีแดง และห้องที่ไม่มีการใช้ให้เป็นสีเขียว อย่างนี้ต้องเขียนโค้ดยังไงคะ

webmaster
webmaster
Wed 6 Aug 2008 19:53:08
ก็ต้องดูสิครับว่าในฐานข้อมูลคุณใช้ field ใดระบุข้อมูลนี้ ก็ไปตรวจสอบที่ field นั้นๆว่าเป็นค่าใด จากนั้นก็เปลี่ยนสีเท่านั้น
BaRaMos
BaRaMos
Mon 18 Aug 2008 09:56:30

กลับมาถามอีกแล้ว อิอิ

1.มีหน้า index ที่มี drop-down สำหรับเลือกห้องประชุม (ชื่อห้องประชุมดึงมาจาก db)

2.มีหน้าแผนผังห้องประชุมทั้งหมด (เป็นimage)

สิ่งที่ต้องการ

ที่หน้าแผนผัง เมื่อคลิกที่ตำแหน่งห้องประชุมที่ต้องการ(ทำการ map ไว้ที่ตำแหน่งห้องประชุมแต่ละห้อง) แล้วให้เด้งไปหน้า index โดยที่ drop-down แสดงชื่อห้องประชุมที่เลือกจากหน้าแผนผัง

ขอบคุณค่ะ

webmaster
webmaster
Mon 18 Aug 2008 11:35:15
ก็เพียงรับค่ามาแล้วก็เอาค่าที่เขาเลือกมาตรวจสอบว่าตรงกับค่าใด ลองหาดูในกระทู้เก่าๆครับ เคยยกตัวอย่างโค๊ดให้ดูไว้
BaRaMos
BaRaMos
Mon 18 Aug 2008 13:59:27

โอเคค่ะ ขอบคุณค่ะ ^_^

Reply
Name:
E-mail:
Home | Services | Forum | Classified | Directories | Support | Contact
ATOM feed RSS 0.9 feed RSS 1.0 feed RSS 2.0 feed
Copyright © 2005 - 2007 Modoeye.com, All Rights Reserved.
Disclaimer | Privacy policy | Term of Use | Term of Services
Valid XHTML Valid CSS! PHP: Hypertext Preprocessor MySQL database Apache Powered! FreeBSD Power to serve
Modoeye Sitemap Client login