AdRock Posted March 28, 2008 Share Posted March 28, 2008 This is my code I have for a search form and it works perfectly. The problem is I don't know if i can add COUNT to the query to get the number of records that match that condition if (isset($address)) { $sql = "SELECT id, userid, seats_available, start_street, start_postcode, end_street, end_postcode, TIME_FORMAT(depart_time,'%H:%i') as depart, MATCH(start_street, start_postcode, end_street, end_postcode) AGAINST('$address*' IN BOOLEAN MODE) as score FROM carshare WHERE MATCH(start_street, start_postcode, end_street, end_postcode) AGAINST('$address*' IN BOOLEAN MODE) "; } else { $sql = "SELECT id, userid, seats_available, start_street, start_postcode, end_street, end_postcode, TIME_FORMAT(depart_time,'%H:%i') as depart FROM carshare WHERE 1=1 "; } if (isset($seats)) { $sql .= "AND seats_available = '$seats' "; } if (isset($departure)) { $sql .= "AND depart_time = '$departure' "; } if (isset($address)) { $sql .= "ORDER BY score, $order ASC"; } else { $sql .=" ORDER BY $order ASC"; } I need to count the number of records so i can paginate the results. Is it possible to count the number of records using something like SELECT COUNT (*) , MATCH(start_street, start_postcode, end_street, end_postcode) AGAINST('$address*' IN BOOLEAN MODE) as score FROM carshare WHERE MATCH(start_street, start_postcode, end_street, end_postcode) AGAINST('$address*' IN BOOLEAN MODE) Link to comment https://forums.phpfreaks.com/topic/98399-count-when-using-full-text-search/ Share on other sites More sharing options...
beebum Posted March 29, 2008 Share Posted March 29, 2008 After $result = mysql_query(... Do $num_records = mysql_num_rows($result); Link to comment https://forums.phpfreaks.com/topic/98399-count-when-using-full-text-search/#findComment-503776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.