Jump to content

uraniumdeer

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

uraniumdeer's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks a bunch - off to mees around with it then :)
  2. Yeah... ofcourse, i was thinking it was only the querystring and not the query itself - sorry...
  3. ehm... define it in the "root" of the PHP tag i suppose [code] <?php $trainerqry6=mysql_query("SELECT DISTINCT trainers.trainer_id as trainerid, trainers.trainer AS trainer FROM trainers"); ... ... ... ?> [/code]
  4. I'm still quite new to PHP but threw myself into a bigger project, I'm trying to caode a forum. I do realize that it's a big task, but I'm not that far from finishing it. My problem is that I'd like to list the users that are online, much like this forum does, list logged in people, and visitors - but i have absolutely no idea how to do this. Any help would be appreciated - a push in the right direction will suffice, though a solution with comments to explain how it work would be really nice :)
  5. First of, remember to increment your $i ($i++) As far as i know, you can't get the variables defined in a function. You need to either define the variables before your function, or "return" the values. [code] class Foo {     function PlayerStats($mid) {         $get_stats = 'SELECT * FROM users WHERE mid="$mid" limit 1';         $usr_stats = mysql_query($get_stats) or die(mysql_error());         $i=0;         while($stats = mysql_fetch_assoc($usr_stats)){             $player_name[$i] = $stats['username'];             $player_email[$i] = $stats['email'];             $player_race[$i] = $stats['race'];             $player_turns[$i] = $stats['turns'];             $player_covert_turns[$i] = $stats['covert_turns'];             $player_tylium[$i] = $status['tylium'];             $player_production[$i] = $stats['alert_status'];             $player_commander[$i] = $status['commander'];             $player_status[$i] = $status['status'];             $i++;         }         return array("name" => array($player_name), "email" => array($player_email), "race" => array($player_race), "turns" => array($player_turns), "covertturns" => array($player_covert_turns), "tylium" => array($player_tylium),  "production" => array($player_production), "commander" => array($player_commander), "status" => array($player_status));     } }[/code] with this you could call the values with: [code] $foo = new Foo(); $plrsts = $foo->PlayerStats($mid); echo $plrsts['name'][0]; [/code] The above code is quite messy, and could most likely easely get cleaned up - but i noticed you limited your search to only return 1 result, therefor the while, and the extra arrays shouldn't be nessesary: [code] class Foo {     function PlayerStats($mid) {         $get_stats = 'SELECT * FROM users WHERE mid="$mid" limit 1';         $usr_stats = mysql_query($get_stats) or die(mysql_error());         $stats = mysql_fetch_assoc($usr_stats));         return $stats;     } }[/code] call this with [code] $foo = new Foo(); $plrsts = $foo->PlayerStats($mid); echo $plrsts['username']; echo $plrsts['email']; [/code] I havn't tested this so i can't guarenteee it will work first try...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.