MySQL Help

Status
Not open for further replies.

NSA

sudo apt-get thefuckout.tar.gz
Dec 9, 2011
715
86
Hello!

I am trying to make a script that will select 5 random people from the database each time the page is refreshed.

For instance say there was 100 people in a database with premium = 1
I want MySQL to select 5 random of them each time the page is loaded so it always displays different ones

Can anyone help?
 

NSA

sudo apt-get thefuckout.tar.gz
Dec 9, 2011
715
86
I just want to select the VIP user's & if they are VIP to be shown on a page...
 

Deion

Posting Freak
Jul 3, 2010
1,273
300
I just want to select the VIP user's & if they are VIP to be shown on a page...
You don't understand what MySQL fetching is, i'm asking what do you want it to select, just random VIP's no names? Random VIP's with their names and motto's? Random VIP's with their names, motto's, credits, ect?
 

NSA

sudo apt-get thefuckout.tar.gz
Dec 9, 2011
715
86
I want VIP's with Name's, Coins, Last Login & If they're online or not.

Sorry it took so long for me to understand.
 

Tronscript

Member
Aug 18, 2012
93
8
I think this is what you want:
PHP:
<?php
$LIMIT = 5; # The amount of users you want returned/
$query = mysql_query("SELECT * FROM users WHERE premium = '1' LIMIT = '" . $LIMIT . "'");
 
while($vip = mysql_fetch_assoc($query)) {
    $username = $vip['username'];
    $motto = $vip['motto'];
    $coins = $vip['coins'];
    $isOnline = $vip['online'];
    $lastLogin = date('F j @ g:i', $vip['last_online']);
    switch($isOnline) {
        case 1:
            return $username . ' is currently online!';
        break;
        case 0:
            return $username . ' is currently offline.';
        break;
    }
}
?>

The online part may be wrong, because I forgot what Phoenix calls the column.
 
Status
Not open for further replies.

Users who are viewing this thread

Top