|
 |
|
โค้ดแบ่งหน้ามีปัญหากับการ Query ข้อมูลที่ถูก JOIN มาครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?
$current_page = 1;
if(isset($_GET['page'])){
$current_page = $_GET['page'];
}
$row_per_page = 10;
$start_row = ($current_page -1) * $row_per_page;
$sql_cheak = "select SQL_CALC_FOUND_ROWS *";
$sql_cheak .=" from tb_rent_customer, tb_type_room, tb_rent_room, tb_room, tb_status_room
where
tb_rent_customer.R_id = tb_room.R_id AND
tb_rent_customer.RR_code_room = tb_rent_room.RR_day_room AND
tb_rent_customer.T_id_type = tb_type_room.T_id_type AND
tb_rent_customer.S_idcode_status = tb_status_room.S_idcode_status ";
$sql_cheak .="order by R_rent_cus DESC ";
$sql_cheak .= "LIMIT $start_row, $row_per_page;";
$rscheak = mysql_query($sql_cheak);
?>
<table cellspacing="0" cellpadding="5" width="100%">
<tr bgcolor="#99CC99">
<th>ลำดับที่</th>
<th>เลขที่ห้อง</th>
<th>เช็คอินท์</th>
<th>เช็คเอาท์</th>
<th>พักกี่วัน</th>
<th>ประเภทห้อง</th>
<th>สถานะห้องพัก</th>
</tr>
<?
while($arrchek = mysql_fetch_assoc($rscheak)){
if($arrchek['S_idcode_status'] == '2' or $arrchek['S_idcode_status'] == '3'){
if($bg == "white"){
$bg = "99cc99";
} else {
$bg = "white";
}
?>
<tr align="center" bgcolor="<? echo $bg;?>">
<td><? echo $arrchek['R_rent_cus']; ?></td>
<td><? echo $arrchek['R_Number_room']; ?></td>
<td><? echo $arrchek['start_date']; ?></td>
<td><? echo $arrchek['end_date']; ?></td>
<td><? echo $arrchek['RR_name_room']; ?></td>
<td><? echo $arrchek['T_name_type']; ?></td>
<td><? echo $arrchek['S_name_status']; ?></td>
</tr>
<?
}
}
?>
</table>
<p><center>
<?
$found_rows = mysql_query("select FOUND_ROWS();");
$total_row = mysql_result($found_rows,0,0);
$total_pages = ceil($total_row / $row_per_page);
$url = $_SERVER['PHP_SELF'];
if($current_page > 1 ) {
$pg = $current_page - 1;
echo "<a href=\"$url?page=$pg\">Previous</a>";
}
echo "$current_page";
if($current_page < $total_pages){
$pg = $current_page + 1;
echo "<a href=\"home.php?page=$pg&url=cheak_new_room.php\">Next</a>";
}
?>
</center>
เอาไปลองใช้ดูนะครับลองปรับเปลี่ยนดูครับ สู้ๆๆๆ
|
 |
 |
 |
 |
Date :
2012-10-03 23:06:56 |
By :
น้องเบิร์ดมือใหม่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|