# -------------------------------------------------------------------- function show_table($order,$id,$npages,$nrows,$max_rows,$from,$to) { if ($to > $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 ($numrows > 0) { # create table with id = "media" echo "\n"; echo ""; echo ""; echo '' . "\n"; echo '' . "\n"; echo "\n"; $count=0; # a little magic to start showing the correct pages # the idea is to determine the start (and end, but that's just the end of the while-loop) # of the current pagination, determined by $id # for example: if our id = 3 and we show 10 pages per block the pages are from 1 - 10 # if our id = 21 and we show 10 pages per block the pages are from 21 - 30 # if our id = 20 and we show 10 pages per block the pages are from 11- 20 $pagecount = $id - ($id%$npages - 1); if ($id%$npages == 0) $pagecount = $pagecount - $npages; # lower pagecount because a bit further we do a "pagecount++" before using it. $pagecount -= 1; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { if ($count%$nrows == 0) { $pagecount++; if ($pagecount == $id) { # this tbody (page) will be visible echo "\n"; } else { # these tbody's (pages) are hidden echo "\n"; } } # data for tbodyX # make even/odd rows a different color if ($count%2 == 0) { echo ""; } else { echo ""; } echo ""; echo ""; echo ""; echo "\n"; $count++; } echo "
ImageTitleDescription
\""" . $line['title'] . "" . $line['description'] . "
\n"; } }