How Do I split up an array into pages
Posted: Fri Oct 25, 2002 11:26 am
I am extracting data from a database into an array and I want to know how I can split it into pages, having only a certain amount of entries per page.
I Tried something like this:
I can get it to print he first five but once I click next, it just adds the next five on. Can anyone help?
I Tried something like this:
Code: Select all
<?php
if(!isSet($Count)) { $Count = 0; } // If not set give initial value
if(!isSet($View)) { $View = 5; } // If not set give initial value
if (!isSet($result))
{
$result = mysql_query( "SELECT ID, DATE_FORMAT(E_DATE, '%m.%d.%y %H:%i'), E_ADDR, E_NAME, E_MAIL, E_HTTP, E_COMM FROM TABLE_NAME ORDER BY E_DATE DESC" ); // Perform query
}
if (!$result)
{
print("Query failed.");
exit();
}
else
{
while ( $Count < $View & $entry = mysql_fetch_array($result) )
{
$COUNT++;
$DATE = $entryї"DATE_FORMAT(E_DATE, '%m.%d.%y %H:%i')"];
$ADDR = $entryї"E_ADDR"];
$NAME = $entryї"E_NAME"];
$MAIL = $entryї"E_MAIL"];
$HTTP = $entryї"E_HTTP"];
$COMM = $entryї"E_COMM"];
print(" $DATE $ADDR $NAME $MAIL $HTTP $COMM <BR> ");
$Count++
}
$View+= 5;
print(" <A HREF="$PHP_SELF?View=$View">Next</A> ");
?>