Question

Hello everyone

First off I would like to thank you for taking your time to read this. I've got a piece of code (shown below) where I'm grabbing something from an external site and displaying it on a GD Image. When I grab 0 I would like to be able to display the text 'Offline' instead of '0' and 'Online' instead of '1'

Any suggestions on how to do so?

I've tried quite a few different methods and I have not been able to get it to work. Any kind of help will be highly appreciated!

Sincerely yours, Malmoc

$username=$_REQUEST["user"];
$grabstat10 = fopen("http://habplus.com/fansitetools/userStats.php?user={$username}&stat=online", "r"); 
while (!feof($grabstat10)){ 
  $online1 = fgets($grabstat10);
}

Edit (@zerkms):

if ($_GET[$online1] > 0) {
    $online2 = 'online';
} else {
    $online2 = 'offline';
}


if ($online1 == "1") {
    $online2 = 'online';
} else {
    $online2 = 'offline';
}

Those were the two most recent attempts I could find in my history. And I'm sorry for not knowing much about coding. I know I suck, and I am going to buy a book or two on PHP, but I still wanted to try and solve this problem. And it would be lovely if you would assist me since based on what I understood from your post, anyone with basic knowledge on PHP would know the answer to this.

Edit2:

Then later included in a GD Image

imagefttext($image, $fsize, 0, 403, 96, $font_color, './volt.ttf', $online2); 

No correct solution

OTHER TIPS

-Fixed

Okay apparently-

    if ($online1 == "1") {
    $online2 = 'online';
} else {
    $online2 = 'offline';
}

-did the trick!

I'm not quite sure why that didn't work earlier.. Something must've gone wrong.

I'd like to thank everyone who commented, and showed interest in assisting me.

Sincerely yours, Nils

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top