|
 |
|
กรุณาช่วยอธิบาย code นี้ให้ผมเข้าใจ และเงือนไขของมันที่ได้ไหมครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
function getthaidate( $date ){
$_month_name = array("01"=>"มกราคม","02"=>"กุมภาพันธ์","03"=>"มีนาคม","04"=>"เมษายน","05"=>"พฤษภาคม","06"=>"มิถุนายน","07"=>"กรกฏาคม","08"=>"สิงหาคม","09"=>"กันยายน","10"=>"ตุลาคม","11"=>"พฤศจิกายน","12"=>"ธันวาคม");
$y=substr($date,0,4);$mm=substr($date,5,2);$dd=substr($date,8,2);
$yy=$y+543;
$dateT=$_month_name[$mm]." ".$yy;
return $dateT;
}
$days=date("Y-m-d");
ตัวที่ 2
Code (PHP)
<form id="form1" name="form1" method="post" action="print_month_total.php">
<div align="center">
<br>
<input type="submit" name="Submit" value="พิมพ์สรุปยอดรวม" >
<input name="p_month" type="hidden" id="p_month" value="<?=$_POST[p_month]?>">
<input name="a_month" type="hidden" id="a_month" value="<?=$_POST[a_month]?>">
<input name="month_name" type="hidden" id="month_name" value="<?=getthaidate($_POST[month_name])?>">
<input name="check" type="hidden" id="check" value="<?=$_POST[check]?>">
</div>
</form>
สำหรับตัวแรก ผมสงสัยตรงที่ $y=substr($date,0,4);$mm=substr($date,5,2);$dd=substr($date,8,2);
และ $dateT=$_month_name[$mm]." ".$yy;
สำหรับตัวที่ 2 สงสัยว่า ทำไมมันถึงไม่โชว์ปุ่มพิมพ์สรุปยอดรวม เข้าใจว่ามัน hidden อยู่ แต่มองผมเงือนไขไม่่ออกว่าจะให้มันแสดงปุ่มขึ้นมายังไง ช่วยอธิบายให้เข้าใจที่นะครับ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-01-23 14:20:21 |
By :
Spect2um |
View :
971 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำไมลองมารันบน browser มันไม่ขึ้นอะอะ ลองดู code ให้ทีนะครับ
Code (PHP)
<table width="518" height="237" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="516" height="32"> </td>
</tr>
<tr>
<td height="205" valign="top"><div align="center">
<?php
include("config.php");
if($_POST[check]=="การยืมอุปกรณ์กีฬา"){
$sql=mysql_query("select * from tb_member,id_member where tb_member.member_id=id_member.member_id and id_member.date_borrow >='$_POST[p_month]' and id_member.date_borrow <'$_POST[a_month]' and id_member.status=2 order by id desc ");
$nums=mysql_num_rows($sql);
}
if($_POST[check]=="การคืนอุปกรณ์กีฬา"){
$sql=mysql_query("select * from tb_member,id_member where tb_member.member_id=id_member.member_id and id_member.d_sent >='$_POST[p_month]' and id_member.d_sent <'$_POST[a_month]' and id_member.status=3 order by id desc ");
$nums=mysql_num_rows($sql);
}
if($_POST[check]=="ส่งคืนอุปกรณ์กีฬาไม่ตรงเวลา"){
$sql=mysql_query("select * from tb_member,id_member where tb_member.member_id=id_member.member_id and id_member.d_sent >='$_POST[p_month]' and id_member.d_sent <'$_POST[a_month]' and id_member.status=3 and id_member.sent < id_member.d_sent order by id desc ");
$nums=mysql_num_rows($sql);
}
if($_POST[check]=="ค้างส่งอุปกรณ์กีฬา"){
$sql=mysql_query("select * from tb_member,id_member where id_member.sent <'$days' and tb_member.member_id=id_member.member_id and id_member.status='2' order by id desc ");
$nums=mysql_num_rows($sql);
}
?>
</div>
<table width="524" align="left">
<tr height="25" >
<td colspan="4" valign="middle" bgcolor="#00FFFF"><div align="center"><span class="style2">ยอดคนที่<?=$_POST[check]?>
ของเดือน
<?=getthaidate($_POST[month_name])?>
</span></div></td>
</tr>
<tr height="25" >
<td width="33" bgcolor="#00FFFF"><div align="center">ลำดับ</td>
<td bgcolor="#00FFFF"><div align="center">รหัสพนักงาน</td>
<td bgcolor="#00FFFF"><div align="center">ชื่อ - นามสกุล </td>
<td bgcolor="#00FFFF"><span class="style3"></span></td>
</tr><? if($nums<=0){?>
<tr height="25" >
<td bgcolor="#00FFFF"> </td>
<td colspan="2" bgcolor="#00FFFF"><div align="center"><span class="style4">ไม่พบรายชื่อที่ค้นหา</span></div></td>
<td bgcolor="#00FFFF"> </td>
</tr>
<? }?>
<?php
$a=1;
while($fetch = mysql_fetch_array($sql)) {
?>
<tr height="25" >
<td bgcolor="#00FFFF"><div align="center">
<?=$a?>
</div></td>
<td width="137" bgcolor="#00FFFF"><div align="center">
<?=$fetch[emp_id]?>
</td>
<td width="210" bgcolor="#00FFFF"><div align="center">
<?=$fetch[name]?>
</td>
<td width="124" bgcolor="#00FFFF"><a href="detail_borrow.php?member_id=<?=$fetch[member_id] ?>" class="style3"><div align="center">รายละเอียดการยืม</td>
</tr>
<?
$a++;
}
?>
<tr height="25">
<td colspan="4" bgcolor="#00FFFF"> </td>
</tr>
<? if($num>=1){?>
<tr height="25">
<td colspan="7" bgcolor="#FFFFFF">
<form id="form1" name="form1" method="post" action="print_month_total.php">
<div align="center">
<br>
<input type="submit" name="Submit" value="พิมพ์สรุปยอดรวม" >
<input name="p_month" type="hidden" id="p_month" value="<?=$_POST[p_month]?>">
<input name="a_month" type="hidden" id="a_month" value="<?=$_POST[a_month]?>">
<input name="month_name" type="hidden" id="month_name" value="<?=getthaidate($_POST[month_name])?>">
<input name="check" type="hidden" id="check" value="<?=$_POST[check]?>">
</div>
</form></td>
</tr>
<? }?>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
</tr>
</table>
สำหรับตัวที่ 1 สงสัยอีกอย่างคือ substr($date,0,4); หรือ 5,2 มันคืออะไร
|
 |
 |
 |
 |
Date :
2012-01-23 15:33:13 |
By :
Spect2um |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีคนตอบเลยหรอ ครับ 
|
 |
 |
 |
 |
Date :
2012-01-23 20:02:21 |
By :
Spect2um |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอ่อ ไม่มีใครจะตอบของผมเลยหรอครับ พอดีติดแค่ตรงนี้นิดเดียวเองครับ งานก็จะเสร็จแล้ว รบกวนทีนะครับ
|
 |
 |
 |
 |
Date :
2012-01-25 10:31:16 |
By :
Spect2um |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันไม่เข้าเงื่อนไข if($num>=1){ มันก็ไม่เจอซิครับ คงไม่เกียวกะ browser หรอก
|
 |
 |
 |
 |
Date :
2012-01-25 11:09:31 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|