How can I nodify the code below to, by default display the 1st 10 resutls from the query, then at the bottom, display a list Page 1 of 2 | 3 | 4 | 5 and so on.?
<?php
include('dbConn.php');
$i="";
$linkID = mysql_connect("localhost", "$dbUser", "$dbPass");
if ($linkID != FALSE) {
mysql_select_db("$dbName", $linkID);
$resultID = mysql_query("SELECT * FROM images WHERE catID='$catID'", $linkID);
$tot=mysql_num_rows($resultID);
while($row = mysql_fetch_assoc($resultID)) {
$iName= $row['imageName'];
$iID= $row['imageID'];
$iWords = $row['keywords'];
$desc = $row['descTxt'];
print "<img src='images/small/".$iID.".jpg' align='left' alt='".$iWords."' border='2' bordercolor='black' height='120'>";
print "<b>".$iName."</b><br>";
print "<font class='main'>";
if($desc!=null) {
include("$desc");
}
//print "This is where I need to add a nice little description for this image.<br>Now I've just got to get off my lazy but and do it.";
print "</font>";
print "<a href='photos.php?imageID=".$iID."'>Click here to see more about this photograph!</a>";
print "<br clear='all'><hr>";
}
}
else {
print "Bad Connection";
}
mysql_close($linkID);
?>
I've tried using the limit for my sql, but I get errors. Any help is appreciated.
Thanks.
Well, I uh... don't know much about PHP, but couldn't you set the displaying part of the code(the whole thing) In a for-loop, and st a variable so that whenever it reaches a number, set next page?
Sorry if I am not much help... I am still a newbie at this :(
Use something like this
$query = "SELECT * FROM table LIMIT $limit,25";
$result = mysql_db_query($db,$query,$connect);
while($row = mysql_fetch_assoc($result)) {
$iName= $row['imageName'];
$iID= $row['imageID'];
$iWords = $row['keywords'];
$desc = $row['descTxt'];
print "<img src='images/small/".$iID.".jpg' align='left' alt='".$iWords."' border='2' bordercolor='black' height='120'>";
print "<b>".$iName."</b><br>";
print "<font class='main'>";
if($desc!=null) {
include("$desc");
}
//print "This is where I need to add a nice little description for this image.<br>Now I've just got to get off my lazy but and do it.";
print "</font>";
print "<a href='photos.php?imageID=".$iID."'>Click here to see more about this photograph!</a>";
print "<br clear='all'><hr>";
}
}
else {
print "Bad Connection";
}