Dear all,
I want to inform that the query return zero result? does anyone know how to revised my code so in case my query return zero result and it will echo "search result =0"

here is my the code, I have try it but still it doesn't inform that "search result =0" if the query return zero result. please revised it:

$today= date("Y-m-d");

$result = mysql_query("SELECT * FROM t_master_reg r, t_master_category c WHERE r.dt_reg_reminder <='$today' AND (r.dt_reg_end >='$today') AND r.id_category = c.id_category");

if (!$result) {echo"search result=0";}
else
{
			$x=1;
		while ($data = mysql_fetch_object($result)) 
		{ 
			echo"<tr>
			<td >$x<br></td>
			<td >$data->no_reg</td>
			<td >$data->category_name<br></td>
			<td >$data->reg_subject<br></td>
			<td >$data->dt_reg_end<br></td>
			<td >$data->reg_link</td>
			</tr>";
			
			$x++;
   
		}
}

mysql_num_rows will tell you how many records were returned by the query.

mysql_num_rows will tell you how many records were returned by the query.

thanks nav33 i have try the mysql_num rows and it work. I really appreciated it ..thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.