Jump to content

Search pagnation not working???


darkfreaks

Recommended Posts

ok i fixed the other problem however now on search pagnation is only showing one result instead of 25 can anyone see where i am going wrong???

 

 

<?php
define('IN_PHPBB', true);
$phpbb_root_path = '../architect-jobs-forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
require "../db_conn.inc.php";
$page_title = 'Architect Job Postings';
include ('../includes/header.php'); 
?>
<table width="100%"  border="0" cellspacing="0" cellpadding="2">
   <tr>
   <td align="left" valign="top"><h1><img src="/images/sq_3.gif" width="17" height="17" hspace="5" vspace="5" align="left">Job Postings</h1></td>
   <td align="right" valign="bottom"><a href="http://www.arkitectum.com/architect-jobs/jobs.php?action=job"><img src="/images/but_post_job.gif" alt="Post an architect job" width="108" height="24" hspace="4" vspace="4" border="0"></a></td>
   </tr>
   </table>
<table width="100%"  border="0" cellspacing="1" cellpadding="2">
       <tr>
         <td align="left"><p><b>Job Seekers:</b> Subscribe to our mailing list and receive 
		daily emails with the latest job postings.
		</p>
	  <form action="http://www.arkitectum.com/architect-jobs-forum/profile.php?mode=register" method="post">
	  <p><input type="text" id="email" name="email" value="email address" onfocus="this.value=''" /><input name="Submit" type="submit" value="Subscribe"></p></form></td>
         <td align="right" valign="bottom"> </td>
       </tr>
     </table>
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" class="forumline">
   <tr>
   <th class="thTop" align="center">Job Title</th>
<th align="center">Location</th>
<th align="center">Posted</th>
   </tr>

 <?php
 if (isset($_GET['page'])) { $page = $_GET['page']; }else{ $page = 1; }
$max_results = 25;
$from = (($page * $max_results) - $max_results);
if (isset($_POST['Search'])) {


$total_results =  "SELECT * FROM jobs WHERE NOW() < expires  AND paid = '1' ";	
$total_pages = ceil($total_results / $max_results); 
  $keyword = trim($_POST['keyword']);
  
  if($_POST['keyword']!=''){
 
 $find = mysql_real_escape_string(htmlentities($_POST['keyword']));
 $find = strtoupper($find);
 $find = strip_tags($find);
 $find = trim ($find); 
 
    if(($_POST['category']!='')&&($_POST['location']!='')){

	  $total_results .=  "AND category = '".mysql_real_escape_string($_POST['category'])."'  
   	              OR location = '".mysql_real_escape_string($_POST['location'])."' 
				  OR title LIKE '%$find%' ORDER BY job_id DESC LIMIT $from,$max_results";
				  $search = TRUE;

 	 }
  elseif(($_POST['category']!='')&&($_POST['location']=='')){

	   		$total_results .=  "AND category = '".mysql_real_escape_string($_POST['category'])."' OR title LIKE '%$find%' ORDER BY job_id DESC LIMIT $from,$max_results";
			   $search = TRUE;

    }
  elseif(($_POST['category']=='')&&($_POST['location']!='')){
   		
		      $total_results .=  " AND location = '".mysql_real_escape_string($_POST['location'])."' OR title LIKE '%$find%' ORDER BY job_id DESC LIMIT $from,$max_results";
	           $search = TRUE;

}
else
{

$total_results .= "AND title LIKE '%$find%' ORDER BY job_id DESC LIMIT $from,$max_results";
	           $search = TRUE;

}

}

else{
if($_POST['location']!=''){// Check if the location isnt empty
       if($_POST['category']==''){ // Check if category is empty 
       
	 $total_results .=  "AND location = '".mysql_real_escape_string($_POST['location'])."' ORDER BY job_id DESC LIMIT $from,$max_results"; 
	   $search = TRUE;

   }// End if category is empty
  }// End if location isnt empty

      	    if($_POST['category']!=''){// Check if the category isnt empty
           if($_POST['location']==''){ // Check if location is empty 
       
	$total_results .=  "AND category = '".mysql_real_escape_string($_POST['category'])."' ORDER BY job_id DESC LIMIT $from,$max_results"; 
	   $search = TRUE;


   }// End if location is empty
  }// End if category isnt empty	
       
	    if($_POST['category']!=''){// Check if the category isnt empty
           if($_POST['location']!=''){ // Check if location is empty 
       
	   $total_results .=  "AND category = '".mysql_real_escape_string($_POST['category'])."' AND location = '".mysql_real_escape_string($_POST['location'])."' ORDER BY job_id DESC LIMIT $from,$max_results"; 
	   $search = TRUE;

      }// End Else
   }// End if location isnt empty
  }// End if category isnt empty	
  
  if($search){
$aa = mysql_query($query) 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>";
 if($page > 1){ 
   $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>&nbsp"; 
} 
} 
if($page < $total_pages){ 
   $next = ($page + 1); 
   echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$next\"> >></a> "; 
}




 }// End While  
 echo "</table>";
  }// End if Search is true
  else
  {
  
  echo 'No search term selected.';?>

Link to comment
https://forums.phpfreaks.com/topic/91351-search-pagnation-not-working/
Share on other sites

This is for Izebryte isnt it? Your client...

 

Well

 

$total_results =  "SELECT * FROM jobs WHERE NOW() < expires  AND paid = '1' ";

 

You didnt run this query

 

$total_results =  "SELECT * FROM jobs WHERE NOW() < expires  AND paid = '1' ";	
$total_pages = ceil($total_results / $max_results); 

 

to

 

 

 

$total_results =  "SELECT * FROM jobs WHERE NOW() < expires  AND paid = '1' ";

$total_results = mysql_query($total_results);
$total_results = mysql_num_rows($total_results);	
$total_pages = ceil($total_results / $max_results); 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.