MySQL & PHP Question

SpaceshipSpaceship
Watch

freeflow

Established Member
Impact
13
How can I make the "if" statement do something if the mysql query finds a result?

$sql = 'SELECT * FROM `Domains` WHERE `status` LIKE \'%delete%\';

if ($sql == ???) {

Do something;

}

Thanks for your help.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
<?php
$query = mysql_query('SELECT * FROM `Domains` WHERE `status` LIKE \'%delete%\'');
if (mysql_num_rows($query) > 0) {
	# Do something
}
?>
 
Last edited:
0
•••
PHP:
$query = mysql_query("
        SELECT * 
        FROM Domains 
        WHERE status LIKE '%delete%'
"); 
if (mysql_num_rows($query) > 0) 
{ 
         while ($res = mysql_fetch_array($query))
         {
              // $res['something']...
         }
}
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
NameMaxi - Your Domain Has Buyers
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back