Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Limiting Mysql output

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
Watch
Impact
19
Hey
Code:
PHP:
<?
$country = $_GET['country'];
$searchpass = $_GET['searchpass'];
$dbusername="zubair";
$dbpassword="";
$database= "z_game";
if ($searchpass == "aa") {
    mysql_connect(localhost, $dbusername, $dbpassword);
    @mysql_select_db($database) or die("Unable to select database");
    $sql = mysql_query("Select * From user where country  = '".$country."' ORDER BY RAND() LIMIT 3")  ;

    while ($row = mysql_fetch_assoc($sql)) {
        	echo $row['username'] . "\n" ;
echo "?\n";
	  	echo $row['health'].  "\n" ;
echo "?\n";
		echo $row['level']. "\n";
echo "?\n";
	      echo $row['money']. "\n";
echo "?\n";
    }
}
else {
echo "error\n";
}
?>
i am trying to get it to output ONLY the results where health and money are > 20
what do i do? can i just put it in in the QUERY ?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
$sql = mysql_query("
    SELECT * 
    FROM user 
    WHERE country  = '".$country."'
        AND health > 20
        AND money > 20
    ORDER BY RAND()
    LIMIT 3
");
?
 
0
•••
PHP:
<?
$country = $_GET['country'];
$searchpass = $_GET['searchpass'];
$dbusername="zubair";
$dbpassword="";
$database= "z_game";
if ($searchpass == "aa") {
    mysql_connect(localhost, $dbusername, $dbpassword);
    @mysql_select_db($database) or die("Unable to select database");
    $sql = mysql_query("Select * From user where country  = '".$country."' ORDER BY RAND() LIMIT 3")  ;

    while ($row = mysql_fetch_assoc($sql)) {
        if ($row['health'] > 20 && $row['money'] > 20) {
            echo $row['username'] . "\n" ;
            echo "?\n";
            echo $row['health'].  "\n" ;
            echo "?\n";
            echo $row['level']. "\n";
            echo "?\n";
            echo $row['money']. "\n";
            echo "?\n";
        }
    } else {
        echo "error\n";
    }
}
?>

SV, don't know if you can do that, so I did it this way..

Blah, don't use this. If you get 3 results and it doesn't display them.. :/
 
0
•••
Yes, you can. ;)
 
0
•••
SecondVersion said:
PHP:
$sql = mysql_query("
    SELECT * 
    FROM user 
    WHERE country  = '".$country."'
        AND health > 20
        AND money > 20
    ORDER BY RAND()
    LIMIT 3
");
?
its getting health and money from the db right?
 
0
•••
It's getting everything.

SELECT *
 
0
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Portfolio sites: new ways to sort, filter and group your domains
Your public portfolio page has a few new tools for visitors. Portfolio: Newest first The sort menu now has "Newest first". It shows the...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back