Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ช่วยดูโค้ดให้หน่อยครับ วันที่มันออกแต่ 1 ม.ค. 2513 ปีมันก็ผิดอะครับ



 

ช่วยดูโค้ดให้หน่อยครับ วันที่มันออกแต่ 1 ม.ค. 2513 ปีมันก็ผิดอะครับ

 



Topic : 090300



โพสกระทู้ ( 120 )
บทความ ( 0 )



สถานะออฟไลน์




วันที่

Code (PHP)
<?
	session_start();
	include "config.inc.php";
?>
<!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=windows-874" />  
<title>Untitled Document</title>
  <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
  $(function() {
    $( "#datepicker" ).datepicker({dateFormat : 'yy-mm-dd'});
	   $( "#datepicker1" ).datepicker({dateFormat : 'yy-mm-dd'});
  });
  </script>
<style type="text/css">
<!--
.style1 {
	font-family: JasmineUPC;
	font-weight: bold;
	font-size: 24px;
}
.style23 {font-family: JasmineUPC; font-size: medium; font-weight: bold; }
.style24 {font-family: JasmineUPC}
.style25 {	font-size: 24px;
	font-weight: bold;
}
.style26 {	font-family: JasmineUPC;
	font-weight: bold;
	font-size: x-large;
}
.style34 {color: #3399CC}
.style45 {font-family: JasmineUPC; font-weight: bold; font-size: large; }
-->
</style>
  <style type="text/css">
<!--
.style48 {	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: xx-large;
}
.style49 {font-size: 14px}
-->
  </style>
</head>
<body>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="5" align="center" valign="top"><script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','1024','height','300','src','images/12311','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/12311' ); //end AC code
</script>
        <noscript>
          <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="1024" height="300">
          <param name="movie" value="images/12311.swf" />
          <param name="quality" value="high" />
          <embed src="images/12311.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="1024" height="300"></embed>
        </object>
        </noscript></td>
  </tr>
  <tr>
    <td colspan="5" align="center" valign="top"><table width="1020" border="0" cellspacing="0" cellpadding="0">
    </table></td>
  </tr>
  <tr>
    <td width="465" height="63" align="center" valign="middle" background="images/Nantestee_02.jpg" ><marquee direction="left" scrolldelay="150">
      Welcome  to Apartment  Nan  DD-Place
    </marquee></td>
    <td width="121" height="63" align="center" valign="bottom" background="images/Nantestee_03.jpg" bgcolor="#FF0000" ><div align="center" class="style26"><a href="index.php" class="style34">หน้าหลัก</a></div></td>
    <td width="153" height="63" align="center" valign="bottom" background="images/Nantestee_04.jpg" ><span class="style26"><a href="test.php"> จองที่พัก</a></span></td>
    <td width="116" height="63" align="center" valign="bottom" background="images/Nantestee_05.jpg" ><span class="style26"><a href="maphotel.php">แผนที่</a></span></td>
    <td width="169" height="63" align="center" valign="bottom" background="images/Nantestee_06.jpg" ><span class="style26"><a href="webboard_user.php">เว็บบอร์ด</a></span></td>
  </tr>
  <tr>
    <td colspan="5" valign="top" background="images/Nantestee_08.jpg" width="1024" height="15" ><table width="1020" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="256"><table width="100" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="3">&nbsp;</td>
            <td width="100"><?
		if ($valid_user==""){
		include"check_login1.php";
		}else{
		  $sql4="select * from person where username='$valid_user'";
			  $result4=mysql_query($sql4);
			  $read_data4=mysql_fetch_array($result4);
			  $id_per=$read_data4[id_per];
			  $username=$read_data4[username];
			  $name=$read_data4[name];
			  $surname=$read_data4[surname];
			   $id_card=$read_data4[id_card];
			    $addr=$read_data4[addr];
				 $phone=$read_data4[phone];
			  $job=$read_data4[job];
			  $pic=$read_data4[pic];
?></td>
          </tr>
          <tr>
            <td width="3">&nbsp;</td>
            <td width="100"><br />
                    <table width="251" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td height="29" colspan="2"><div align="center"><span class="style1">สวัสดีคุณ :</span>&nbsp;&nbsp;&nbsp;<? echo"$username";?></div></td>
                      </tr>
                      <tr>
                        <td height="29" colspan="2" bgcolor="#FFCB65"><p align="center">
                            <?
			  if($pic==""){
			  echo"<img src=images/nopic.jpg width='100' height='100' border='0'>";
			  }else{
			echo"<img src='pic/$pic' width='100' height='100' border='0'>";
			}
			  ?>
                          &nbsp;</p></td>
                      </tr>
                      <tr>
                        <td width="120" bgcolor="#FFCB65"><div align="right" class="style23">ชื่อ - นามสกุล :</div></td>
                        <td width="145" bgcolor="#FFCB65"><label>&nbsp;&nbsp;<span class="style23">&nbsp;<? echo"$name&nbsp;&nbsp;$surname"; ?></span></label></td>
                      </tr>
                      <tr>
                        <td bgcolor="#FFCB65">&nbsp;</td>
                        <td bgcolor="#FFCB65">&nbsp;</td>
                      </tr>
                      <tr>
                        <td bgcolor="#FFCB65"><div align="right" class="style23">อาชีพ :</div></td>
                        <td bgcolor="#FFCB65"><label>&nbsp;&nbsp;<span class="style23">&nbsp;<? echo"$job"; ?></span></label></td>
                      </tr>
                      <tr>
                        <td bgcolor="#FFCB65">&nbsp;</td>
                        <td bgcolor="#FFCB65">&nbsp;</td>
                      </tr>
                      <tr>
                        <td height="60" colspan="2" bgcolor="#FFCB65"><p align="center" class="style49"><span class="style24 style24"><? echo "<a href=\"logout.php\"onclick=\"return confirm('คุณต้องการออกจากระบบใช่หรือไม่')\" ><br />
                   [ออกจากระบบ]</font></a>"; ?>&nbsp;&nbsp;</span><span class="style24">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="detail.php">[ประวัติส่วนตัว]</a></span></p></td>
                      </tr>
                    </table>
                       <? 
  }
  ?>
              <p>
                  </p></td>
          </tr>
          <tr>
            <td width="3">&nbsp;</td>
            <td width="100"><img src="images/Nantestee_18.jpg" width="253" height="70" /></td>
          </tr>
          <tr>
            <td width="3">&nbsp;</td>
            <td width="100">&nbsp;</td>
          </tr>
          <tr>
            <td rowspan="4">&nbsp;</td>
            <td width="100"><span class="style26"><a href="http://www.moohin.com/037/">สถานที่ท่องเที่ยว</a></span></td>
          </tr>
          <tr>
            <td width="100">&nbsp;</td>
          </tr>
          <tr>
            <td width="100"><span class="style26"><a href="guestbook.php">ติดต่อเว็บมาสเตอร์</a></span></td>
          </tr>
          <tr>
            <td width="100">&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td width="100"><span class="style45"><a href="admin_login.php">Admin (เฉพาะผู้ดูแลระบบเท่านั้น)</a></span></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td width="100">&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td width="100">&nbsp;</td>
          </tr>
        </table></td>
        <td valign="top"><p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <form id="form1" name="form1" method="post" action="check_building_a.php">
          <table width="662" border="2" align="center" cellpadding="0" cellspacing="2" bordercolor="#00FF00">
            <tr>
<?
    $sql4="select * from tb_rooma where id_rooma='$id_rooma'";
	$result4=mysql_query($sql4);
$read_data4=mysql_fetch_array($result4);
$id_rooma=$read_data4['id_rooma'];
$room_type=$read_data4['room_type'];
$price_mounta=$read_data4['price_mounta'];
$price_daya=$read_data4['price_daya'];
?>
              <td width="90" bgcolor="#FF4242"><div align="center"><strong>เลขที่ห้องพัก</strong></div></td>
              <td width="114" bgcolor="#FF4242"><div align="center"><strong>ประเถทห้องพัก</strong></div></td>
              <td width="183" bgcolor="#FF4242"><div align="center"><strong>วันที่เข้าพัก</strong></div></td>
              <td width="128" align="center" bgcolor="#FF4242"><strong>วันที่ออก</strong></td>
              <td width="204" align="center" bgcolor="#FF4242"><strong>ราคาที่พัก</strong></td>
              <td width="103" bgcolor="#FF4242"><div align="center"><strong>จำนวนวันที่พัก</strong></div></td>
            </tr>
            <tr>
              <td height="31" align="center" valign="middle" bgcolor="#CCCCFF"><div align="center"><strong><? echo "$id_rooma"; ?></strong></div></td>
              <td align="center" valign="middle" bgcolor="#CCCCFF"><div align="center"><strong>
                  <? if ($room_type==1){
																														echo "รายวัน";
																														}else{
																														echo "รายเดือน";}
																														?>
              </strong></div></td>
              <td align="center" valign="middle" bgcolor="#CCCCFF"><strong>
                <label>
                <input name="check_ina" type="text" id="datepicker" />
                </label>
              </strong></td>
              <td align="center" valign="middle" bgcolor="#CCCCFF"><label>
                <?
				 if($room_type==1){
               echo "<input name='check_outa' type='text' id='datepicker1' />"; 
			   }else{
			   echo "ไม่ต้องระบุ";}
                 ?>
                </label>
              </td>
              <td align="center" valign="middle" bgcolor="#CCCCFF"><strong>
                <?
	if($room_type==1){
	echo "$price_daya";
	}else{
	echo "$price_mounta";
	}
    ?>
                &nbsp;</strong></td>
              <td align="center" valign="middle" bgcolor="#CCCCFF"><strong>
                <label>
                <?
				 if($room_type==1){
               echo "<input name='num_daya' type='text' id='num_daya' size='5' />"; 
			   }else{
			   echo "ไม่ต้องระบุ";}
                 ?>
                </label>
              </strong> </td>
            </tr>
          </table>
          <p>
<?
	function DateThai($strDate)
	{
		$strYear = date("Y",strtotime($strDate))+543;
		$strMonth= date("n",strtotime($strDate));
		$strDay= date("j",strtotime($strDate));
		$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
		$strMonthThai=$strMonthCut[$strMonth];
		return "$strDay $strMonthThai $strYear";
	}
	$strDate = "$check_ina";
?>
<?
	function DateThai1($strDate1)
	{
		$strYear = date("Y",strtotime($strDate1))+543;
		$strMonth= date("n",strtotime($strDate1));
		$strDay= date("j",strtotime($strDate1));
		$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
		$strMonthThai=$strMonthCut[$strMonth];
		return "$strDay $strMonthThai $strYear";
	}
	$strDate1 = "$check_outa";
?>
<?
    $sql8="select * from tb_detailbookinga where id_rooma='$id_rooma'";
	$result8=mysql_query($sql8);
  while($read_data8=mysql_fetch_array($result8)){
$id_rooma=$read_data8['id_rooma'];
$room_type=$read_data8['room_type'];
$check_ina=$read_data8['check_ina'];
$check_outa=$read_data8['check_outa'];
?>
<? echo "วันที่เข้า        ".DateThai($strDate); ?>  ถึง   <? echo "วันที่เข้า        ".DateThai1($strDate1); ?> <br>
          </p>
          <?
		  }
          ?>




Tag : PHP, JavaScript









ประวัติการแก้ไข
2013-02-04 18:28:41
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-02-04 18:20:38 By : narongsad View : 846 Reply : 5
 

 

No. 1



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

สถานะออฟไลน์


ไม่ต้องเอามาหมดก็ได้ ขอดูแค่ส่วนที่มีปัญหา สมมุติ 500 บรรทัดไม่ต้องไล่ดูหมดเลยหรอครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-04 18:22:39 By : Ex-[S]i[L]e[N]t
 


 

No. 2



โพสกระทู้ ( 120 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : Ex-[S]i[L]e[N]t เมื่อวันที่ 2013-02-04 18:22:39
รายละเอียดของการตอบ ::
อ๋อครับๆ ขอโทดครับ พอดีผมไม่รู้ว่ามันไม่ดีตั้งแต่ตรงไหน ไม่รู้จริงๆครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-04 18:26:51 By : narongsad
 

 

No. 3



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ผมดูแล้ว เจอปัญหาที่ตัวแปร
$strDate = "$check_ina";
และ
$strDate1 = "$check_outa";

ซึ่ง $check_ina และ $check_outa ไม่เคยมีการกำหนดค่ามาก่อน พูดง่ายๆ คือมันไม่มีค่าใดๆ เลย (ถ้าโปรแกรมทั้งหมดมีแค่นี้)
และเมื่อเอาไปแปลงเป็นวันที่สำหรับ strtotime() มันก็จะกลายเป็น 1 ม.ค. 1970 เมื่อปี + 543 เข้าไปก็ได้ 2513
เดาว่า คุณคงรับตัวแปรจากฟอร์มโดยใช้ register_globals แต่มีการปิดใช้งานส่วนนี้อยู่
ดังนั้นลองเปลี่ยนเป็นแบบนี้ดูครับ

$strDate = $_REQUEST['check_ina'];
$strDate1 = $_REQUEST['check_outa'];


ประวัติการแก้ไข
2013-02-04 18:39:14
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-04 18:37:40 By : cookiephp
 


 

No. 4



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

มีอีกครับ

Code (PHP)
<?
    $sql8="select * from tb_detailbookinga where id_rooma='$id_rooma'";
	$result8=mysql_query($sql8);
  while($read_data8=mysql_fetch_array($result8)){
$id_rooma=$read_data8['id_rooma'];
$room_type=$read_data8['room_type'];
$check_ina=$read_data8['check_ina'];
$check_outa=$read_data8['check_outa'];
?>
<? echo "วันที่เข้า        ".DateThai($strDate); ?>  ถึง   <? echo "วันที่เข้า        ".DateThai1($strDate1); ?> <br>
          </p>
          <?
		  }
          ?>



ส่วนของการแสดงผลวันที่เนี่ย คุณใช้ค่าจาก $strDate และ $strDate1
ซึ่งมันได้ถูกกำหนดค่าไว้ครั้งเดียวก่อนหน้านี้ (บรรทัดที่ 257 และ 269) และไม่มีการเปลี่ยนแปลงอีก
ดังนั้นทุกครั้งที่แสดงผล มันจะเป็นข้อมูลจาก form เท่านั้น
ถ้าจะแสดงวันที่จากฐานข้อมูลจะต้องเปลี่ยนบรรทัด 280 เป็น

Code (PHP)
<? echo "วันที่เข้า        ".DateThai($check_ina); ?>  ถึง   <? echo "วันที่เข้า        ".DateThai1($check_outa); ?> <br>


แล้วก็ศึกษาเพิ่มเติมหน่อยนะครับ
การเขียนของคุณมีการเขียนที่ซ้ำซ้อนมากมาย ทั้งการกำหนดตัวแปร ไปจนถึงการเขียนฟังก์ชั่น
เช่น DateThai และ DateThai1 ทำงานเหมือนกัน แต่เขียนเป็นสองฟังก์ชั่น ไม่จำเป็นเลยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-04 18:48:07 By : cookiephp
 


 

No. 5



โพสกระทู้ ( 120 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 4 เขียนโดย : cookiephp เมื่อวันที่ 2013-02-04 18:48:07
รายละเอียดของการตอบ ::
ขอบคุณอย่างมากจริงๆครับ พอดีผมทำโปรเจคจบอะครับผมดันจับได้ มันเปลี่ยนไม่ได้จิงๆ ครับ ผมไม่ถนัดอะครับ php เนี้ย ยังไงก็ขอบคุณำหรับคำตอบทุกๆคำตอบครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-04 19:06:27 By : narongsad
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยดูโค้ดให้หน่อยครับ วันที่มันออกแต่ 1 ม.ค. 2513 ปีมันก็ผิดอะครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่