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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -