code แบ่งหน้า PHP (comment บทความ)
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา code แบ่งหน้า PHP (comment บทความ)
code แบ่งหน้า PHP (comment บทความ)
Copy
พอดีทำโค้ด comment บทความแล้วมีปัญหาค่ะ
- ใส่ code แบ่งหน้าแล้วมีปัญหาค่ะ คือ www.xxx.com/content.php?cont_id=7 แต่พอใส่ code แบ่งหน้าแล้วเป็นแบบนี้ค่ะ www.xxx.com/content.php?s_page=0&urlquery_str= ทำให้เวลาคลิกลิ้งค์แล้วกลายเป็นหน้าเปล่าๆ
***จาก code แบ่งหน้า PHP ด้วย CSS
<?
$sql_comm="select * from tb_comment where cont_id='$cont_id' order by comm_id DESC";
$query_comm=mysql_query($sql_comm);
$total=mysql_num_rows($query_comm); //เรียงลำดับ comment จากมากไปน้อย
$temp=$total;
$temp=$temp+1;
$e_page=5;
if(!isset($_GET['s_page'])){
$_GET['s_page']=0;
}else{
$chk_page=$_GET['s_page'];
$_GET['s_page']=$_GET['s_page']*$e_page;
}
$sql_comm.=" LIMIT ".$_GET['s_page'].",$e_page";
$qr=mysql_query($sql_comm);
if(mysql_num_rows($qr)>=1){
$plus_p=($chk_page*$e_page)+mysql_num_rows($query_comm);
}else{
$plus_p=($chk_page*$e_page);
}
$total_p=ceil($total/$e_page);
$before_p=($chk_page*$e_page)+1;
while($fetch_comm=mysql_fetch_array($qr)){
$temp--;
?>
<div>
<table width="400" border="0" cellpadding="0" cellspacing="0" style="float:left; width:735px; margin:10px 0 10px 0;">
<tr>
<td width="12"><img src="image/comment_head_left.png" /></td>
<td width="711" style="background:url(image/comment_head.png) no-repeat top;">ความคิดเห็นที่ <?=$temp?> เรื่อง <?=$result[cont_name]?></td>
<td width="12"><img src="image/comment_head_right.png" width="12" height="25" /></td>
</tr>
<tr>
<td width="12" style="background:url(image/comment_detail_left.png) repeat-y top;"></td>
<td width="711" style="background:#b6b6b6 repeat top;">
<?
$detail=$fetch_comm[comm_detail];
$detail_rude=CheckRude($detail);
echo $detail_rude;
?>
</td>
<td width="12" style="background:url(image/comment_detail_right.png) repeat-y top;"></td>
</tr>
<tr>
<td width="12"><img src="image/comment_foot_left.png" /></td>
<td width="711" style="background:url(image/comment_foot.png) no-repeat top;">เขียนโดย :
<?
$detail_aut=$fetch_comm[comm_author];
$detail_rude_aut=CheckRude($detail_aut);
echo $detail_rude_aut;
?>
</td>
<td width="12"><img src="image/comment_foot_right.png" /></td>
</tr>
</table>
<? }?>
</div>
<?php if($total>0){ ?>
<div class="browse_page">
<?php
// เรียกใช้งานฟังก์ชั่น สำหรับแสดงการแบ่งหน้า
page_navigator($before_p,$plus_p,$total,$total_p,$chk_page);
?>
</div>
<?php } ?> คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ