Hello Experts,
I have a script which queries a mysql db and returns its results in a HTML table.
The problem is there are hundreds of returns, so a paging script would be in order.
Based off of the tutorials I found elsewhere in EE, I built the Paging Script below.
My problem is I don't know how to deal with the paging script's need to use the Header Function.
This is the last part of a new section of a company website I am setting up.
Hence the high point value...
Thanx,
DLG
----- Table Maker Script -----
// evaluate whether or not Collection has been passed
$value = (isset($_GET) && array_key_exists('collecti
on', $_GET)) ? $_GET['collection'] : false;
// If collection is not set, display a paginated table of collections
if ($value === false) {
$resultn = mysql_query("SELECT * FROM tblItems GROUP BY item_collection") or die("Sql Error : " . mysql_error());
echo '<table class="content">';
echo '<tr>';
$c = 0;
while($row1 = mysql_fetch_array($resultn
)) {
$c++;
echo '<td>';
echo '<a href="collection_table.php
?collectio
n=' . $row1['item_collection'] . '">';s
echo '<img class="content" src="'. $row1['image_path'] . $row1['image_file_low'] . '"><br/>' ;
echo $row1['item_collection'];
echo '</a>';
echo '</td>';
if ($c == 5) {
$c = 0;
echo '</tr>';
echo '<tr>'; //end the old row and begin a new one
}
}
echo '</tr>';
echo '</table>';
echo '/<div>";
} else {
----- Table Maker Script -----
----- Paging Script -----
<?PHP
if ( $_REQUEST['number'] == NULL ){
$limit = 10;
} else {
$limit = $_REQUEST['number'];
}
if ($_REQUEST['page']==NULL){
$start = 0;
} else {
$start = $_REQUEST['page'];
}
if($_GET['page'] < 0){
header("Location: category_searchy.php?page=
0&number="
.$limit);
}
$query = mysql_query("SELECT * FROM tblItems LIMIT $start, $limit") or die(mysql_error());
while ($row = mysql_fetch_array ($query) ) {
echo '<p>'.$row['item_number'].
'</p>';
}
$previous = $start - $limit;
$next = $start + $limit;
echo '<a href="category_searchy.php
?page='.$p
revious.'"
>Previous<
/a> - ';
echo '<a href="category_searchy.php
?page='.$n
ext.'">Nex
t</a>';
?>
----- Paging Script -----
Start Free Trial