Mikhak
Active Member
وقتي ميخوام ليستمو صفحه بندي كنم يعني اگه بيشتر از مثلا 20 تا بود بره صفحه بعد
ليست رو مياره ولي وقتي 123 رو ميزنم اين ارور رو ميده
Sorry, such file does'n exist
اينم كدش
فكر كنم اشكال تو متغير self باشه
اگه ميشه راهنمايي كنين
------------
سينا
ليست رو مياره ولي وقتي 123 رو ميزنم اين ارور رو ميده
Sorry, such file does'n exist
اينم كدش
کد:
<?php
if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
$index = 0;
global $prefix, $db, $aid;
$rowsPerPage = 5;
// by default we show first page
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$query = "SELECT st_name FROM " . $user_prefix . "_webclass LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');
// print the random numbers
while($row = mysql_fetch_array($result))
{
echo $row['st_name'] . '<br>';
}
echo '<br>';
// how many rows we have in database
$query = "SELECT COUNT(st_name) AS numrows FROM " . $user_prefix . "_webclass";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= " $page "; // no need to create a link to current page
}
else
{
$nav .= " <a href=\"$self?page=$page\">$page</a> ";
}
}
// creating previous and next link
// plus the link to go straight to
// the first and last page
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";
$first = " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
$prev = '&nbsp;'; // we're on page one, don't print previous link
$first = '&nbsp;'; // nor the first page link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = '&nbsp;'; // we're on the last page, don't print next link
$last = '&nbsp;'; // nor the last page link
}
// print the navigation link
echo $first . $prev . $nav . $next . $last;
include("footer.php");
// and close the database connection
?>
فكر كنم اشكال تو متغير self باشه
اگه ميشه راهنمايي كنين
------------
سينا