Forum Moderators: coopster

Message Too Old, No Replies

page count record set

back ---- forward

         

nanat

6:58 am on Aug 13, 2009 (gmt 0)

10+ Year Member



aim trying for create and page record count in php and mysql.. i try my codes in 6 hours but i cant solve it so dats y i decide to get help..

this my idea..


limit = 4
back 5 6 7 8 forward

on click forward
9 10 11 12

on click backward
1 2 3 4

his my code


function StudentPagination($offset)
{
$sqlQuery = "SELECT StudentID FROM students";
$result = mysql_query( sprintf( $sqlQuery ) );

$MaxValue = mysql_num_rows($result);
$MaxPerPage = 15;
$OffSet = 0;
$onSet = 0;
$PageCounter = 1;
$TotalPages = ceil( $MaxValue / $MaxPerPage );
$cutTotalpages = ($TotalPages = 3);

echo $TotalPages;

if ($MaxValue >= 10)
{
$rdata = '<div>Total Students: <b>'.$MaxValue.'</b> <br>Page: <font style="font-weight: bold; font-size: 12px;">';
for ($i = 0; $i < $TotalPages; $i++)
{
$OffSet = $MaxPerPage * $i;

if ($OffSet == $offset)
{
$rdata .= ' '.($i + 1).' ';
}
else
{

$rdata .= '<a href="index.php?option=students&page='.$OffSet.'">'.($i + 1).'</a>';

}
}
}
else if($cutTotalpages >= 3)

{
for ($r = 0; $r < $cutTotalpages; $r++)
{
$onSet = $MaxPerPage * $r;

if ($onSet == $OnSet)
{
$rdata .= ' '.($r + 1).' ';
}
else
{

$rdata .= '<a href="index.php?option=students&page='.$onSet.'">Forward</a>';

}
}

}
else
{
return '&nbsp;';
}

return $rdata .='</font></div>';
}

if problems persist consult an expert ^^

tnx :D

coopster

3:14 pm on Aug 15, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't have time to test the code, nanat. Where are you stuck?

nanat

12:14 am on Aug 17, 2009 (gmt 0)

10+ Year Member



yeah i understand ^^ in this page

else if($cutTotalpages >= 3)

{
for ($r = 0; $r < $cutTotalpages; $r++)
{
$onSet = $MaxPerPage * $r;

if ($onSet == $OnSet)
{
$rdata .= ' '.($r + 1).' ';
}
else
{

$rdata .= '<a href="index.php?option=students&page='.$onSet.'">Forward</a>';

}
}

}

coopster

12:51 pm on Aug 18, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What is this part doing?
if ($onSet == $OnSet) 
{