Jump to content

mysql_num_rows() expects parameter 1 to be resource,


xanie

Recommended Posts

can u help me with this guys?? tnx..

 

$category  =  $_GET['category'];
$search  = $_GET['search'];
$tableName="warranty"; 
$targetpage = "search.php"; 
$limit = 10;

$page = mysql_real_escape_string($_GET['page']);
if($page)
{
 $start = ($page - 1) * $limit;
}
else
{
 $start = 0;
} 


if($category == 'id')
{
  $query  = "SELECT COUNT(*) as num FROM $tableName WHERE warranty_id = '$search'";
  $query1  = "SELECT * FROM $tableName WHERE warranty_id = '$search' ORDER BY warranty_id ASC LIMIT $start, $limit";
}
else if($category == 'name')
{
  $query  = "SELECT COUNT(*) as num FROM $tableName WHERE full_name = '$search'";
  $query1  = "SELECT * FROM $tableName WHERE full_name like '%$search%' ORDER BY warranty_id ASC LIMIT $start, $limit";
}
else
{
  $query  = "SELECT COUNT(*) as num FROM $tableName ";
  $query1  = "SELECT * FROM $tableName ORDER BY warranty ASC LIMIT $start, $limit";
}
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];

$stages = 3;

   // Get page data

$result = mysql_query($query1);

// Initial page num setup
if ($page == 0){$page = 1;}
$prev = $page - 1;
$next = $page + 1;	  
$lastpage = ceil($total_pages/$limit); 
$LastPagem1 = $lastpage - 1;	
?>
<?php

 $row_count   =  mysql_num_rows($result);
 if($row_count == 0 )
 {
  echo " <tr>
   <td colspan='12' align='center'>No <font color='red'><b>'$search'</b></font> found. </td>
  </tr>
 ";
 }
 else
 {
   while($rows = mysql_fetch_array($result))
   {
 $id   = $rows['warranty_id'];
 $month  = $rows['date_purchased_month'];
 $year  = $rows['date_purchased_year'];
 $day  = $rows['date_purchased_day'];

 $fullname = $rows['full_name'];
 $address = $rows['address'];

 $city  = $rows['city'];
 $email  = $rows['email'];
 $gender  = $rows['gender'];
 $agegroup = $rows['age_group'];
 $model  = $rows['model'];
 $lens  = $rows['lens'];
 $frame  = $rows['frame'];
 $ppaid  = $rows['price_paid'];

 $how  = $rows['how_did_you_hear'];

 $where  = $rows['where_did_you_buy'];

 $performance= $rows['performance'];
 $value  = $rows['value'];
 $quality = $rows['quality'];

 $suggestions= $rows['suggestions'];
 $date_activation=$rows['date_of_activation'];

 echo "
    <tr>
	 <td><a href='/warranty/edit/?warranty_id=".$id."' onclick='return edit()'> EDIT</a></td>
	 <td> ".$id."</td>
	 <td> ".$month."</td>
	 <td> ".$day."</td>
	 <td> ".$year."</td>
	 <td> ".$fullname."</td>
	 <td> ".$address."</td>
	 <td> ".$city."</td>
	 <td> ".$email."</td>
	 <td> ".$gender."</td>
	 <td> ".$agegroup."</td>
	 <td> ".$model."</td>
	 <td> ".$lens."</td>
	 <td> ".$frame."</td>
	 <td> ".$ppaid."</td>
	 <td> ".$how."</td>
	 <td> ".$where."</td>
	 <td> ".$performance."</td>
	 <td> ".$value."</td>
	 <td> ".$quality."</td>
	 <td> ".$suggestions."</td>
	 <td> ".$date_activation." </td>
   <td><a href='/quotations/delete/?warranty_id=".$id."' style='color:red' onclick='return del()'>DELETE  </a></td>
  </tr>
  ";
   }

  }

?>

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.