I have copied and slightly altered a code to allow my mysql query to display a certain amount of rows of data and then display links to more pages (Prev, Next, and page numbers) - otherwise known as Pagination.
However, the links show up only as plain text. I am hoping someone will look at my code and see what I'm missing here - I've been looking at it for 3 days and see nothing that should be different...
any help is greatly appreciated!
note: the page the script is running on is called, simply page.php
<?php
$b=0;
include ('approved.php');
echo "$header";
@mysql_connect($host, $user, $pass) or die("ERROR--CAN'T CONNECT TO SERVER");
@mysql_select_db($db) or die("ERROR--CAN'T CONNECT TO DB");
$limit = 4;
$query_count = "SELECT count(*) FROM inventory";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page)){
$page = 1;
}
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM inventory LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0){
echo("Nothing to Display!");
}
$bgcolor = "#E0E0E0"; // light gray
echo("<table>");
while($row = mysql_fetch_array($result)){
$id=mysql_result($result,$b,"id");++$b;
$pic_place = "pictures/";
$thumb = "small$id.jpg";
$image_size = getimagesize ("pictures/$thumb");
$height = ($image_size[1] * 75) / $image_size[0];
if ($bgcolor == "#E0E0E0"){
$bgcolor = "#FFFFFF";
}else{
$bgcolor = "#E0E0E0";
}
echo("<tr bgcolor=".$bgcolor."><td>");
echo "<form method=\"post\" action=\"car.php\">
<input type=\"hidden\" name=\"id\" value=\"$id\">
<input type = image src= \"$pic_place$thumb\"
height=$height width=75 border=0></form>";
echo("</td><td>");
echo($row["year2"]);
echo("</td><td>");
echo($row["color"]);
echo("</td><td>");
echo($row["make"]);
echo("</td><td>");
echo($row["model"]);
echo("</td><td>");
echo($row["type"]);
echo("</td></tr>");
}
echo("</table>");
if($page != 1){
$pageprev = $page--;
echo("<a href=\"page.php&page=$pageprev\">PREV".$limit."</a> ");
}else{
echo("PREV".$limit." ");
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"page.php?page=$i\">$i</a> ");
}
}
if(($totalrows % $limit) != 0){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"page.php?page=$i\">$i</a> ");
}
}
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page++;
echo("<a href=\"page.php?page=$pagenext\">NEXT".$limit."</a>");
}else{
echo("NEXT".$limit);
}
?>