when a search yeilds zero results...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Wilbo
Forum Newbie
Posts: 22
Joined: Fri Jul 25, 2008 5:45 am

when a search yeilds zero results...

Post by Wilbo »

Hi there, I'm making a simple search function for my news article system
and I was wondering if anyone can tell me how I can detect when the search yields no results.

So when there's no matches, it says 'Sorry no matches' or whatever.

I'm doing the usual thing of a LIKE clause in my SELECT statement, and I've tried several things, such as:
if (empty($result)) {
or
if (empty($row)) {
or
if ($result == 0) {
etc etc

but none of them give the desired result :)

I'm sure this is a basic question, so why not help out a noob?

Thanks in advance,

Wilbo
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: when a search yeilds zero results...

Post by jayshields »

Code: Select all

mysql_num_rows()
Please read the manual, search the manual and/or Google search before asking such questions! :)
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: when a search yeilds zero results...

Post by Chalks »

jayshields wrote:Please read the manual, search the manual and/or Google search before asking such questions! :)
The manual is located at php.net
Post Reply