xanie Posted January 30, 2013 Share Posted January 30, 2013 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 https://forums.phpfreaks.com/topic/273816-mysql_num_rows-expects-parameter-1-to-be-resource/ Share on other sites More sharing options...
sowna Posted January 30, 2013 Share Posted January 30, 2013 check whether your query executed without error, replace the below code and check it.... $result = mysql_query($query1) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/273816-mysql_num_rows-expects-parameter-1-to-be-resource/#findComment-1409092 Share on other sites More sharing options...
xanie Posted January 30, 2013 Author Share Posted January 30, 2013 check whether your query executed without error, replace the below code and check it.... $result = mysql_query($query1) or die(mysql_error()); thanks.. it's already fix.. Link to comment https://forums.phpfreaks.com/topic/273816-mysql_num_rows-expects-parameter-1-to-be-resource/#findComment-1409094 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.