Ok, so this is what I have now....:
if ($id) {
$query = "SELECT * FROM content where id='$id' ";
$result = mysql_query ($query)
or die ("query 2 failed");
$row = mysql_fetch_array($result);
printf("<img src=\"images/img_%s.jpg\">\n<br>", $row["code"]);
}
//-----
else {
//-----
$numresults=mysql_query("SELECT * FROM content where id like '$form_id' ");
if (!$numrows) $numrows=mysql_num_rows($numresults);
if (empty($offset)) {
$offset=0;
}
if($fileid) $form_id = $fileid;
$query = "SELECT * FROM content where id like '$form_id' order by id limit $offset,$limit";
$result = mysql_query ($query)
or die ("query 2 failed");
$num_rows = mysql_num_rows($numresults);
echo " <b> $num_rows</b> Matching Results<br><br>\n";
while ($row = mysql_fetch_array ($result))
{
for ($i = 0; $i < mysql_num_fields ($result); $i++)
{
if ($i > 0)
print ("<br>");
if ($i == 0){
print "<b>Id: </b>";
}
else if ($i == 1){
print "<b>Article: </b>";
}
else if ($i == 2){
print "<b>code: <a href=\"$PHP_SELF?id=$row[id]\"><img
src=\"images/thumb_$row[code].jpg\"></a></b>";
}
else{
print "<b>Date:</b><br>";
}
print ($row[$i]);
}
print "<br><br><center><img src='black.gif' width=590 height=1 border=0></center>";
print ("<P>");
}
if ($offset >= $limit) {
$prevoffset = $offset - $limit;
print "<a href=\"xxx.php?offset=$prevoffset&fileid=$form_id&numrows=$numrows\">PREV</a> \n";
}
$pages=intval($numrows/$limit);
if ($pages < ($numrows/$limit)){
$pages=($pages + 1);
}
for ($i = 1; $i <= $pages; $i++) {
$newoffset = $limit*($i-1);
if ($newoffset == $offset) {
print "$i \n";
} else {
print "<a href=\"xxx.php?offset=$newoffset&fileid=$form_id&numrows=$numrows\">$i</a> \n";
}
}
//show next if not last
for ($i = 1; $i < $numrows; $i+2) {
$newoffset = $i-1;
if ($newoffset == $offset) {
print "$i \n";
} else {
print "<a href=\"xxx.php?offset=$newoffset&fileid=$form_id&numrows=$numrows\">$i</a> \n";
}
}
with the if $numrow line near the top, but i'm still getting endless lnes of 'ones' on my results page....
(By the way, I'm really sorry to be takeing up so much of your time)