Jump to content

num_rows isnt a valid resource?


darkfreaks

Recommended Posts

<?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";
				  $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($total_results) or die(mysql_error());
$num = mysql_num_rows($row); 
     while($row = mysql_fetch_array($aa)){
 extract($row); 
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> "; 
}
echo'</p>';



 }// End While  
   }
 echo "</table>";

 echo"<p align='right'>"; 
$self=$_SERVER['PHP_SELF'];
$nav = '';



}// End if form was submitted 


include_once ('../includes/footer.htm'); 
?>

Link to comment
Share on other sites

<?php
if($search){
$aa = mysql_query($total_results) or die(mysql_error());
$num = mysql_num_rows($row); 
     while($row = mysql_fetch_array($aa)){
 extract($row); 
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> "; 
}
echo'</p>';


?>

Link to comment
Share on other sites

ok now they pagnation links wont show ???

 

<?php
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> "; 
}
echo'</p>';




?>

Link to comment
Share on other sites

	$page = 1;
$total_pages = 15;
    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>&nbsp"; 
	} 
} 
if($page < $total_pages){ 
	$next = ($page + 1); 
	echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$next\"> >></a> "; 
}

?>

 

gives...

<< [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15  >>

Link to comment
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.