MySQL & PHP Question

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
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
Close
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
Close
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
Close
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back