Jump to content

Recommended Posts

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>'; 
  }
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/95650-php-paging/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/95650-php-paging/#findComment-489711
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.