PRodgers4284 Posted March 11, 2008 Share Posted March 11, 2008 I have a search script that outputs results in a table, i want to set the number of rows that is displayed on a page, if its over a certain number it add a page link eg page 1, 2 etc. Can anyone provide some help or advice on how to do this? I have the following code that i want to add to paging to: <?php if ($_POST['submit']){ $sql = "SELECT * FROM job"; $jobcat = mysql_real_escape_string(trim($_POST['jobcatergory'])); $jobloc = mysql_real_escape_string(trim($_POST['joblocation'])); if ($jobcat != '' && $jobloc != '') { $sql .= " WHERE jobcatergory LIKE '$jobcat%' AND joblocation LIKE '%$jobloc%'"; } else if ($jobcat != '' && $jobloc == '') { $sql .= " WHERE jobcatergory LIKE '%$jobcat%'"; } else if ($jobloc != '' && $jobcat == '') { $sql .= " WHERE joblocation LIKE '%$jobloc%'"; } $query = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) > 0) { while ($job = mysql_fetch_array($query)) { $username=$job["username"]; $id=$job["id"]; $jobtitle=$job["jobtitle"]; $jobcatergory=$job["jobcatergory"]; ?> <table class="sofT" cellspacing="0"> <tr> <td class="Header">Company Name</td> <td class="Header">Job Title</td> <td class="Header">Job Location</td> <td class="Header">View Job</td> <td class="Header">Contact Employer</td> </tr> <tr> <td class="Body"><?php echo $job["username"]; ?></td> <td class="Body"><?php echo $job["jobtitle"]; ?></td> <td class="Body"><?php echo $job["jobcatergory"]; ?></td> <td class="Body"><?php echo "<a href='searchjobview.php?username=$username&id=$id'>View Job</a>"?></td> <td class="Body"><?php echo "<a href='searchemployerdetails.php?username=$username'>Contact Employer</a>"?></td> </tr> <br> </table> <?php } } else { echo '<p>There are no search results with the search criteria you entered.</p>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/95650-php-paging/ Share on other sites More sharing options...
sasa Posted March 11, 2008 Share Posted March 11, 2008 are you ever see more then one record? Quote Link to comment https://forums.phpfreaks.com/topic/95650-php-paging/#findComment-489705 Share on other sites More sharing options...
peranha Posted March 11, 2008 Share Posted March 11, 2008 Search Pagination That is what I believe you want. http://www.tonymarston.net/php-mysql/pagination.html There is a page with code, and explains it well. Quote Link to comment https://forums.phpfreaks.com/topic/95650-php-paging/#findComment-489707 Share on other sites More sharing options...
PRodgers4284 Posted March 11, 2008 Author Share Posted March 11, 2008 are you ever see more then one record? I Want to limit the number of rows that the table display when the search is carried out, if it more than 10 at link "1" to display the rest of the records. Im unsure how to do this, can u provide any help, id really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/95650-php-paging/#findComment-489711 Share on other sites More sharing options...
nadeemshafi9 Posted March 11, 2008 Share Posted March 11, 2008 Search Pagination That is what I believe you want. http://www.tonymarston.net/php-mysql/pagination.html There is a page with code, and explains it well. ahh hella script i learned alot from that when he wrote it Quote Link to comment https://forums.phpfreaks.com/topic/95650-php-paging/#findComment-489715 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.