darkfreaks Posted February 20, 2008 Share Posted February 20, 2008 My code is only returning the previous button and no data? is there anyway to fix this? ??? <?php $page =(isset($_GET['page']))?$_GET['page']:1; $max_results = 25; $from = (($page * $max_results) - $max_results); function clean($string){ $new = trim(strip_tags(mysql_real_escape_string(htmlentities($string)))); return $new; } if (isset($_POST['Search'])) { $total_results = "SELECT * FROM jobs WHERE NOW() < expires AND paid = '1' "; if ($_POST['keyword'] != '') { $find = strtoupper(clean($_POST['keyword'])); $location = clean($_POST['location']); $category = clean($_POST['category']); if (($_POST['category'] != '') && ($_POST['location'] != '')) { $total_results .= "AND category = '" .$category."' OR location = '" .$location . "'OR title LIKE '%$find%'";; } elseif (($_POST['category'] != '') && ($_POST['location'] == '')) { $total_results .= "AND category = '" . $category . "' OR title LIKE '%$find%' ";; } elseif (($_POST['category'] == '') && ($_POST['location'] != '')) { $total_results .= " AND location = '" . $location ."' OR title LIKE '%$find%'";; } else { $total_results .= "AND title LIKE '%$find%'"; } $search = true; } else { if ($_POST['location'] != '') { if ($_POST['category'] == '') { $total_results .= "AND location = '" . $location ."' "; $search = true; } } if ($_POST['category'] != '') { if ($_POST['location'] == '') { $total_results .= "AND category = '" . $category."' "; $search = true; } } if ($_POST['category'] != '' && $_POST['location'] != '') { $total_results .= "AND category = '" . $category ."' AND location = '" . $location ."' "; $search = true; } } if ($search) { $totalrows = mysql_query($total_results) or die(mysql_error()); $num = mysql_num_rows($totalrows); $total_pages = ceil($num / $max_results); $total_results .="ORDER BY job_id DESC LIMIT $from,$max_results"; $aa = mysql_query($total_results) or die(mysql_error()); while ($row = mysql_fetch_array($aa)) { echo " <tr> <td align='left' valign='top' bgcolor='#F2F5F9'> <b><a href='view-job.php?job_id={$row['job_id']}'>" .stripslashes($row['title']) . "</a></b> <br>" . stripslashes($row['employer']) ." </td> <td align='left' valign='top' bgcolor='#F2F5F9'> {$row['city']}, {$row['location']} </td> <td align='center' valign='top' bgcolor='#F2F5F9' width='70' class='small_10'>" . date('M d, y', strtotime($row['date'])) . " </td> </tr>"; } // End While } echo "</table>"; echo "<p align='right'>"; if ($page <= 1) { echo " <a href='#'><<</a> "; } else { $prev = ($page - 1); echo " <a href=\"" . $_SERVER['PHP_SELF'] . "?page=$prev\"><<</a> "; } for ($i = 1; $i <= $total_pages; $i++) { if (($page) == $i) { echo "[$i] "; } else { echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=$i\">$i</a> "; } } if ($page < $total_pages) { $next = ($page + 1); echo " <a href=\"" . $_SERVER['PHP_SELF'] . "?page=$next\"> >></a> "; } echo '</p>'; } // End if form was submitted include_once ('../includes/footer.htm'); ?> Link to comment https://forums.phpfreaks.com/topic/92177-pagination-probllem/ Share on other sites More sharing options...
Trium918 Posted February 25, 2008 Share Posted February 25, 2008 Did you fix the problem in this script? Link to comment https://forums.phpfreaks.com/topic/92177-pagination-probllem/#findComment-475611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.