Currently, I have a page that lists expenses submitted by my staff. The problem is that it pulls everyyyy row from this table of submitted expenses... So it takes forever to load the page (we have data going back to 2006!!!) I would clear the table, but due to our policies we need to maintain a record of 10 years worth..
In any case, I want this page to list 25 entries, and want to have the option of having pages like <<1|2|3|4|5>> of which each will display 25 entries. The PHP code relevant to discussion is:
<?php
$forms = array();
if ($checkr[4]==2)
$dtfq = mysql_query("SELECT `index`,`time`,`status`,`user` FROM `dtf` ORDER BY `index` desc;");
else
$dtfq = mysql_query("SELECT `index`,`time`,`status`,`user` FROM `dtf` WHERE `user`=".$checkr[0]." ORDER BY `index` desc;");
while($dtf = mysql_fetch_row($dtfq)) {
$newentry = array(1,$dtf[0],$dtf[1],$dtf[2],$dtf[3]);
$forms[] = $newentry;
}
if ($checkr[4]==2)
$crfq = mysql_query("SELECT `index`,`time`,`status`,`user` FROM `crf` ORDER BY `index` desc;");
else
$crfq = mysql_query("SELECT `index`,`time`,`status`,`user` FROM `crf` WHERE `user`=".$checkr[0]." ORDER BY `index` desc;");
while ($crf = mysql_fetch_row($crfq)) {
$newentry = array(2,$crf[0],$crf[1],$crf[2],$crf[3]);
$forms[] = $newentry;
}
for ($i=0; $i<count($forms); $i++) {
for ($j=0; $j<count($forms); $j++) {
if ($forms[$j][2]<$forms[$i][2]) {
$temp = $forms[$j];
$forms[$j] = $forms[$i];
$forms[$i] = $temp;
}
}
}
for ($i=0; $i<count($forms); $i++) {
?>
I've found this resource helpful, but does not meet my needs: Need to pull last x number of rows based on date
Thanks,
TK