|
|
|
PagingPaginationไม่ยอมแบ่งออกเป็นหน้าแค่ไม่ยอมแสดงออกครับผม |
|
|
|
|
|
|
|
อันนี้โค้ดครับ
รบกวนผู้รู้ช่วยดูให้ทีครับ ขอบยคุณครับ โดยผมแบ่งเป็น 10 แถวต่อหน้าอะครับ
<?php
include("connect/connect.php");
$sqltspth = "SELECT * FROM tsp_slideimage WHERE lang = 'th'";
$QueryData = mysqli_query($conDB,$sqltspth);
$sqltspen ="SELECT * FROM tsp_slideimage WHERE lang ='en'";
$QueryDataEn = mysqli_query($conDB,$sqltspen);
$Num_Rows = mysqli_num_rows($QueryData,MYSQLI_ASSOC);
$Per_Page = 5; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$sqltspth .=" order by slideimage_id ASC LIMIT $Page_Start , $Per_Page";
$QueryData = mysqli_query($conDB,$sqltspth);
?>
<form action="" method="post" enctype="multipart/form-data" id="form">
<table class="table table-bordered table-striped" id="sortable1">
<thead>
<tr>
<th width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);"></th>
<th class="width_no">ลำดับ</th>
<th class="width_image">ภาพ</th>
<th class="left"> <a href="">หัวข้อ</a>
</th>
<th class="width_status"> <a href="">สถานะ</a>
</th>
<th class="width_action">การกระทำ</th>
<th class="width_ordering">ลำดับการแสดง</th>
</tr>
</thead>
<tbody class="ui-sortable">
<?php
$i = 1;
if($Page > 1)
{
$i = ($Per_Page * ($Page-1))+1;
}
$Row = 1;
while($ResTsp = mysqli_fetch_array($QueryData,MYSQLI_ASSOC))
{
?>
<tr id="item_id_32">
<td style="text-align: center;"> <input type="checkbox" name="selected[]" value="32">
</td>
<td class="width_no"><?php echo $Row;?></td>
<td class="width_image"><a href=""><img src="HomeSlideTh/InsertHomeSlide/home/r/<?php echo $ResTsp["image"];?>" alt="Banner 2" style="padding: 1px; border: 1px solid #DDDDDD;" border="0"></a></td>
<td class="left"><a href=""><?php echo $ResTsp["title"];?></a></td>
<td class="width_status">
<?php
if($ResTsp["sys_status"]==1)
{
echo "ทำงาน";
}else if($ResTsp["sys_status"]=="0"){
echo "ไม่ทำงาน";
}
?>
</td>
<td class="width_action">
<a href="./HomeSlideTh/InsertHomeSlide/home/EditHomSlide.php?slideimage_id=<?php echo $ResTsp["slideimage_id"];?>" class="btn btn-mini"><i class="icon-pencil"></i> แก้ไข</a>
<a href="./HomeSlideTh/InsertHomeSlide/home/del.php?slideimage_id=<?php echo $ResTsp["slideimage_id"];?>" class="action-delete-single btn btn-mini" id="32"><i class="icon-remove"></i> ลบ</a>
</td>
<td class="width_ordering">
<span><a class="btn btn-mini"><i class="icon-resize-vertical btn-move"></i></a></span>
<a href="" class="btn btn-mini" title="text_moveup"><i class="icon-circle-arrow-up"></i></a>
<a href="" class="btn btn-mini" title="text_move_down"><i class="icon-circle-arrow-down"></i></a>
</td>
<?php
$i++;
$Row++;
}
?>
</tr>
</tbody>
</table>
Total <?php echo $Num_Rows;?> Record : <?php echo $Num_Pages;?> Page :
<?php
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
mysqli_close($conDB);
?>
</form>
Tag : PHP, MySQL, HTML/CSS, CakePHP
|
|
|
|
|
|
Date :
2015-10-31 16:31:06 |
By :
Poae |
View :
644 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับพี่ @TC Admin
|
|
|
|
|
Date :
2015-11-02 10:59:02 |
By :
Poae |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|