Hi, I wonder if this line is correct. It seems not to work in my file if ( ($img_id <= $temp ) and ($temp < $img_id + 10)) {echo $temp;}; Code (markup): I have 28 pictures to be shown, 10 per page, but only 2 pages show up thanks in advance
Try setting a new variable for $img_id+10 before you do the if statement. $img_id_max=$img_id+10; if ( ($img_id <= $temp ) and ($temp < $img_id_max)) {echo $temp;}; PHP:
function lesexamples ($sex) { if ($_GET[page_num] == "") {$page_num = 1;} else {$page_num = $_GET[page_num]; }; $k = mysql_query("SELECT * FROM lesexamples WHERE sex='{$sex}'"); $exemple_qty = mysql_num_rows($k); $page_qty = ceil ($exemple_qty/10); echo '<table width="100%" cellspacing="0" cellpadding="0" border="0">'; $img_id = ($page_id - 1)* 10 +1; $img_id_max=$img_id+10; while ($z = mysql_fetch_array($k)) { $temp++; if ( ($img_id <= $temp ) and ($temp < $img_id_max)) {echo $temp;}; }; echo '<tr><td colspan="2" height="15"></td></tr>'; ?> <tr><td colspan="2" height="15" align="center"> <? for ($i = 1; $i <= $page_qty; $i++) { if ($i == $page_num) { echo $page_num;} else { echo ' <a href="main.php?page_id=3§ion_id='. $_GET[section_id] .'&page_num=' . $i . '">' . $i.'</a> '; }; }; ?> </td></tr> <tr><td colspan="2" height="15" align="center"> <? if ($page_num != 1) { $link_page_num = $page_num - 1; echo '<a href="main.php?page_id=3§ion_id='. $_GET[section_id] .'&page_num=' . $link_page_num . '">Previous</a> ';} else {echo 'Previous ';} if ($page_num != $page_qty) { $link_page_num = $page_num + 1; echo ' <a href="main.php?page_id=3§ion_id='. $_GET[section_id] .'&page_num=' . $link_page_num . '">Next </a>';} else {echo ' Next';} ?> </td></tr> </table> <? }; Code (markup):