Check if mysql query found results PHP -
how check if found results in mysql query in php
for eg
$usersearch=mysql_query("select * users username=$searchboxinput"); if($usersearch==successfull){ //what happens when successfull } else{ //what happens when unsuccessfull }
so if found user matching $searchboxinput , vice vera
use mysql_num_rows()
if(mysql_num_rows($usersearch) > 0){ //what happens when successfull } else{ //what happens when unsuccessfull }
fyi, you shouldn't use mysql_*
functions in new code. no longer maintained and officially deprecated. see red box? learn prepared statements instead, , use pdo or mysqli - this article decide which. if choose pdo, here tutorial.
you may open sql injections.
Comments
Post a Comment