|
 |
|
การแสดงผลวันที่เป็นภาษาไทย หลายๆแถว มีพบข้อผิดพลาด เพราะแสดงได้แถวเดียว |
|
 |
|
|
 |
 |
|
ตอนนี้ผมกำลังทำโปรเจ็คจบครับผม มีปัญหา เกี่ยวกับการแสดงวันที่ในแบบภาษาไทย โดยใช้ ฟังก์ชั่นอาเรย์ในการตรวจสอบครับ ถ้าผม ใส่ค่าแบบปกติคือ yyyy/mm/dd ก็ออกครับ แต่ถ้าเข้าในรูปแบบฟังก์ชั่นแล้ว ปรากฎว่าแปลกรูปแบบได้แต่แถวแรกครับ แถวบรรทัด 2 ไปจะไม่ตรวจสอบ เหมือนมันซ้ำกันครับผม

หน้า code
Code (PHP)
<table width="497" border="1" bordercolor="#FF99FF">
<tr class="smallhand">
<td width="113" align="center">รหัสแจ้งซ่อม</td>
<td width="129" align="center">วันที่แจ้งซ่อม</td>
<td width="79" align="center">รหัสผู้เช่า</td>
<td width="89" align="center">รายละเอียด</td>
<td width="53" align="center" bgcolor="#FFFFFF"></td>
</tr>
<?php
include "../../config/connect_db.php";
include "../../js/thaidate.php";
$strSQL = "SELECT * FROM repair WHERE User_ID = '$_SESSION[ses_user]' ORDER BY Repair_Date DESC; ";
$result = mysql_query($strSQL);
while($rs = mysql_fetch_array($result))
{
?>
<tr>
<td align="center"><?php echo $rs["Repair_ID"]?></td>
<td align="center"><?php $var_date = $rs["Repair_Date"]; //บรรทัดนี้
$thai_month_arr = array("0"=>"","1"=>"มกราคม", "2"=>"กุมภาพันธ์", "3"=>"มีนาคม", "4"=>"เมษายน", "5"=>"พฤษภาคม",
"6"=>"มิถุนายน", "7"=>"กรกฎาคม", "8"=>"สิงหาคม", "9"=>"กันยายน", "10"=>"ตุลาคม", "11"=>"พฤศจิกายน",
"12"=>"ธันวาคม" );
function thai_date($time){
global $thai_month_arr;
$thai_date_return = date("j",$time);
$thai_date_return.= " ".$thai_month_arr[date("n",$time)];
$thai_date_return.= " ".(date("Y",$time)+543);
return $thai_date_return;}
$var_date=strtotime("$var_date");
$var_date= thai_date($var_date);
echo $var_date;
?></td>
<td align="center"><?php echo $rs["User_ID"]?></td>
<td align="center"><a href="rpequipment.php?repair_id=<?php echo $rs["Repair_ID"]?>" class="linkweb">คลิก</a></td>
<td align="center" bgcolor="#FFFFFF"><?php if ($rs["Repair_Status"] == '1')
echo "<img src='../../images/email.png' width='25' height='25'>";
else
echo "<img src='../../images/email_open.png' width='25' height='25'>";
?></td>
</tr>
<?php } ?>
</table>
ขอบคุณล้วงหน้าที่สละเวลามาตอบครับผม
Tag : PHP, MySQL, JavaScript, Windows

|
ประวัติการแก้ไข 2012-09-01 02:59:05 2012-09-01 03:07:19
|
 |
 |
 |
 |
Date :
2012-09-01 02:58:19 |
By :
veeitdata5 |
View :
1149 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
function thai_date($time){
global $thai_month_arr;
$thai_date_return = date("j",$time);
$thai_date_return.= " ".$thai_month_arr[date("n",$time)];
$thai_date_return.= " ".(date("Y",$time)+543);
return $thai_date_return;}
เอาตัวนี้ไปใช้บนสุดครับ เพราะคุณแทรกใน Loop มันเลยประกาศตัวแปร function ซ้ำครับ
|
 |
 |
 |
 |
Date :
2012-09-01 07:39:51 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|