$max_rows) $to = $max_rows - $from; # use mysql's "limit from,to" to select the correct rows $query = "select imagepath,title,description from pagination_images order by " . $order . " limit " . $from . "," . $to; $result = mysql_query($query) or show_error("Query failed: " . mysql_error()); $numrows=mysql_num_rows($result); # if id is lastpageid substract "rest" (= npages on last block) to get startid $max_id = ceil($max_rows / $nrows); if ($id == $max_id ) { if ($id%$npages == 0) { $rest = $npages; } else { $rest = $id%$npages; } $startid = $id - $rest + 1; } else { $startid = $id; } if ($numrows > 0) { # create table with id = "media" echo "
Image | "; echo 'Title | ' . "\n"; echo 'Description | ' . "\n"; echo "
---|---|---|
"; echo " | " . $line['title'] . " | "; echo "" . $line['description'] . " | "; echo "