|
 |
|
ช่วยตัดบรรทัดให้หน่อยครับ แบบว่าผมแบ่งหน้าให้แสดงออกมาเป็นหน้าๆแต่พอหน้ามากมันแสดงให้บรรทัดเดียวคือถ้าแบ่งได้ 40 หน้า |
|
 |
|
|
 |
 |
|
แบบว่าผมแบ่งหน้าให้แสดงออกมาเป็นหน้าๆแต่พอหน้ามากมันแสดงให้บรรทัดเดียวคือถ้าแบ่งได้
40หน้ามันก็จะแสดงแถวเดียวยาวไปเลยผมอยากจะให้แสดง 10 หน้าแล้วขึ้นบรรทัดใหม่
โค๊ดที่ผมเขียนช่วยดูหน่อยครับว่าจะตัดบรรทัดอย่างไร
<?require("config.php")?>
<html>
<head>
<title></title>
<style type="text/css">
<!--
{
font-family:AngsanaUPC,CordiaUPC,sans-serif,Cordia New,courier new,serif;
font-size:16 px;
}
-->
</style>
</head>
<?
$pagesize = 5;
if(empty($pagesize)){
$pagesize=1;
}
$q_sql = "select * from tam";
$q_db_query = mysql_db_query($dbname,$q_sql);
$num_rows = mysql_num_rows($q_db_query);
$rt = $num_rows%$pagesize;
if($rt!=0)
{
$totalpage = floor($num_rows/$pagesize)+1;
}else{
$totalpage = floor($num_rows/$pagesize);
}
$goto =($page-1)*$pagesize;
$sql ="select * from tam order by Qnumber desc limit $goto,$pagesize";
$db_query = mysql_db_query($dbname,$sql);
if(!$db_query)
{
echo ("เอ็กซิคิวต์คำสั่ง SQL ไม่ได้" .mysql_error() );
exit;
}else{
$nums_rows = mysql_num_rows($db_query);
}
?>
<body bgcolor="#fffff1" text="#ff0000" link="#0000ff" vlink="#0000ff">
<div align="center"><font size="3"><strong>กระดานข่าว</strong></font></div>
<?
echo "<font size='1'><strong>หน้าปัจจุบันคือ</strong>: </font>";
for($i=1 ; $i<$page ; $i++)
{
echo "<a href='$PHP_SELF?page=$i'>$i</a> ";
}
echo "<font size=1 color=#ff0000><strong>$page</strong></font> ";
for($i=$page+1 ; $i<=$totalpage ; $i++)
{
echo "<a href='$PHP_SELF?page=$i'> $i </a>";
}
$o=$i - 1;
echo "<font size='1'> [จากหน้าที่:1-$o มีจำนวน $num_rows ข่าว] <strong><font color='#0000FF' size='2'><a href='tam.php'>ฝากข่าว</a></font></strong></font>";
echo "<hr color='#0000ff'>";
$sql = "select * from tam order by Qnumber desc limit $goto,$pagesize";
$result =mysql_db_query($dbname,$sql);
?>
<?$sql="select * from tam order by Qnumber desc limit $goto,$pagesize";
$reslt=mysql_db_query($dbname,$sql);
?>
<? while($row=mysql_fetch_array($reslt)){?>
<?$bgc = ($bgc == "#eeeeee")?"#ffffff":"#eeeeee";?>
<table width="100%">
<tr bgcolor="<?echo $bgc;?>"><td>
<img src="upfile/folder-box.gif" width="14" height="15" alt="" border="0">
<a href="tob.php?Qnumber=<?echo$row['Qnumber']?>"><b><font size="2"><?echo $row['Qtopic']?></font></b></a><br>
<font size="1">โดยคุณ <?echo $row['Qname']?> <?if($row['Qsex']=="ชาย"){?>
<?echo"<img src='upfile/face004.gif' width='15' height='15 alt='' border='0'>"?>
<?}else{?>
<?echo"<img src='upfile/face065.gif' width='15' height='15' alt='' border='0'>"?>
<?}?>
เมื่อวันที่ <?echo $row['Qdate']?>
มีผู้ตอบ <?echo $row['tob']?> มีผู้ชม <?echo $row['do']?></font> </td></tr>
</table>
</body>
<?}?>
<br>
<div align="center">
<a href="tam.php"><font size="3" color="#800000">[ฝากข่าว]</font></a>
<a href="../index.html" target="_parent"><font size="3" color="#800000">[กลับ]</font></a></div><br>
<?require("../footer.php")?>

Tag : - - - -

|
|
 |
 |
 |
 |
Date :
8 เม.ย. 2548 10:18:24 |
By :
uan |
View :
2607 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เข้าใจคำถาม ต้องการให้แสดงเป็นหน้า หรือต้องการให้แสดง เป็นแถวที่กำหนดแล้วเป็นหน้าใหม่ครับ 
|
 |
 |
 |
 |
Date :
11 เม.ย. 2548 17:29:43 |
By :
forress |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แสดงเป็นแถวครับคือว่าจำนวนหน้าที่แสดงออกมามันมีมากอยากจะให้ตัดบรรทัดลงมา
คือจำนวนหน้าขึ้นแบบนี้ครับ
หน้าปัจจุบันคือ1 2 3 4 5 6 7 8 9 10 11 12 13 14 [จากหน้าที่:1-14มีจำนวน 280]
ผมอยากได้แบบนี้ครับ
หน้าปัจจุบันคือ1 2 3 4 5 6 7 8 9 10
11 12 13 14 [จากหน้าที่:1-14มีจำนวน 280]
คือตัดทีละ 10 หน้าแล้วขึ้นบรรทัดใหม่
|
 |
 |
 |
 |
Date :
11 เม.ย. 2548 17:54:55 |
By :
uan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ok ทำได้แล้วครับ
|
 |
 |
 |
 |
Date :
22 เม.ย. 2548 11:06:29 |
By :
uan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
class Paginator{
var $items_per_page;
var $items_total;
var $current_page;
var $num_pages;
var $mid_range;
var $low;
var $high;
var $limit;
var $return;
var $default_ipp;
var $querystring;
var $url_next;
function Paginator()
{
$this->current_page = 1;
$this->mid_range = 7;
$this->items_per_page = $this->default_ipp;
$this->url_next = $this->url_next;
}
function paginate()
{
if(!is_numeric($this->items_per_page) OR $this->items_per_page <= 0) $this->items_per_page = $this->default_ipp;
$this->num_pages = ceil($this->items_total/$this->items_per_page);
if($this->current_page < 1 Or !is_numeric($this->current_page)) $this->current_page = 1;
if($this->current_page > $this->num_pages) $this->current_page = $this->num_pages;
$prev_page = $this->current_page-1;
$next_page = $this->current_page+1;
if($this->num_pages > 10)
{
$this->return = ($this->current_page != 1 And $this->items_total >= 10) ? "<a class=\"paginate\" href=\"".$this->url_next.$this->$prev_page."\">« Previous</a> ":"<span class=\"inactive\" href=\"#\">« Previous</span> ";
$this->start_range = $this->current_page - floor($this->mid_range/2);
$this->end_range = $this->current_page + floor($this->mid_range/2);
if($this->start_range <= 0)
{
$this->end_range += abs($this->start_range)+1;
$this->start_range = 1;
}
if($this->end_range > $this->num_pages)
{
$this->start_range -= $this->end_range-$this->num_pages;
$this->end_range = $this->num_pages;
}
$this->range = range($this->start_range,$this->end_range);
for($i=1;$i<=$this->num_pages;$i++)
{
if($this->range[0] > 2 And $i == $this->range[0]) $this->return .= " ... ";
if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range))
{
$this->return .= ($i == $this->current_page And $_GET['Page'] != 'All') ? "<a title=\"Go to page $i of $this->num_pages\" class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" title=\"Go to page $i of $this->num_pages\" href=\"".$this->url_next.$i."\">$i</a> ";
}
if($this->range[$this->mid_range-1] < $this->num_pages-1 And $i == $this->range[$this->mid_range-1]) $this->return .= " ... ";
}
$this->return .= (($this->current_page != $this->num_pages And $this->items_total >= 10) And ($_GET['Page'] != 'All')) ? "<a class=\"paginate\" href=\"".$this->url_next.$next_page."\">Next »</a>\n":"<span class=\"inactive\" href=\"#\">» Next</span>\n";
}
else
{
for($i=1;$i<=$this->num_pages;$i++)
{
$this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"".$this->url_next.$i."\">$i</a> ";
}
}
$this->low = ($this->current_page-1) * $this->items_per_page;
$this->high = ($_GET['ipp'] == 'All') ? $this->items_total:($this->current_page * $this->items_per_page)-1;
$this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";
}
function display_pages()
{
return $this->return;
}
Go to : PHP MySQL Pagination ทำแบ่งหน้าด้วย PHP กับ MySQL ย่อจำนวนหน้า ในกรณีที่มีจำนวนหน้าเยอะ ๆ
|
 |
 |
 |
 |
Date :
2011-07-15 09:32:33 |
By :
thaicreate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|