나는 아래의 스크립트를 사용하여 페이지 매김을 생성하고 광범위하게 말하자면 작업 스크립트를 사용합니다. 그러나 잘라 내기 및 붙여 넣기 작업이 실제로 링크를 생성하는 방법을 이해하지 못하기 때문에 이 변수는 $ pagination 변수를 사용하여 스크립트에 표시됩니다.PHP 페이지 매김 링크 생성
그것이 에코 무엇 :의
1< a href="index.php?page=2">2< a href="index.php?page=3">3< a hr_ef="?page=2"> Next
없음이 작동하지 않습니다 (클릭) 링크, 나 또한 그래서 그 스타일을 할 수 있도록하려는 것보다는 PHP는 에코보다는 HTML에서 오히려 출력을, 같은 :
<?php
/* Set current, prev and next page */
$page = (!isset($_GET['page']))? 1 : $_GET['page'];
$prev = ($page - 1);
$next = ($page + 1);
/* Max results per page */
$max_results = 10;
/* Calculate the offset */
$from = (($page * $max_results) - $max_results);
/* Query the db for total results.*/
$result = mysql_query("...");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results/$max_results);
$pagination = '';
/* Create a PREV link if there is one */
if($page > 1)
{
$pagination .= '< a href="?page='.$prev.'">Previous</a> ';
}
/* Loop through the total pages */
for($i = 1; $i <= $total_pages; $i++)
{
if(($page) == $i)
{
$pagination .= $i;
}
else
{
$pagination .= '< a href="index.php?page='.$i.'">'.$i.'</a>';
}
}
/* Print NEXT link if there is one */
if($page < $total_pages)
{
$pagination .= '< a hr_ef="?page='.$next.'"> Next</a>';
}
/* Below is how you query the db for ONLY the results for the current page */
$query ="SELECT * FROM ... LIMIT $from, $max_results";
$result=mysql_query($query) or die(mysql_error());
$rsjobinfo=mysql_fetch_assoc($result);
do {?>
<div>
[Individual Row Output]
</div>
<?php } while ($rsjobinfo=mysql_fetch_assoc($result));
echo $pagination;
?>
누군가가 도와 드릴까요 : 아래
<p><?php 1< a href="index.php?page=2">2< a href="index.php?page=3">3< a hr_ef="?page=2"> Next ?> </p>
내가 사용하고 스크립트입니까? 나는 그것의 작은 수정을 상상하지만 언제나처럼, 올바른 방향으로 걷어차기를 평가할 것이다.
감사 댄
하하 나는 더러움이 간단하다는 것을 알았다. 고맙습니다 QD, 나는 태그의 이상한 형식이 스크립트의 일부로 필요할 수 있다고 생각했습니다. (저는 알고 있습니다, 신인). 스타일링은 문제가되지 않아야한다. 다시 한번 감사드립니다, 방대한 단계 앞으로 :) – Dan
@ 댄, 그것을 계속 듣고, 잘 간다;) 행운을 빌어 요! – Quasdunk