Jump to content

Recommended Posts

Hi guys,

 

Me again :)

 

Does anyone know how to do a dynamic image like:

 

on my website i would insert a image that points to , blaaa.blaa.com/status.php?id=1234567890

 

Then depending on teh output of the php file, it would display online or offline.

 

I suppose i would just want the php file to say use this image or this image.

 

Any ideas?

 

Thanks

G

Link to comment
https://forums.phpfreaks.com/topic/160160-solved-online-offline-dynamic-image/
Share on other sites

On/Off Status images usually require information on getting the status of the user.

U may want to check ICQ/MSN/AIM/Yahoo protocols.

 

or create yer own client to pass info to a page (Like some DynDNS clients do, to get an updated ip address)

 

Once ya got the method of On/Off Detection, than its just a matter of following post #2 in this thread.

 

There is no real magic to this, just some thought beforehand

Post 2 doesnt work.

 

I already have teh condition.

 

$status = either 1 or 0

 

it returns correctly but the images dont work

 

If in a html page i refer to the php file instead of blaa.png nothing happens.

 

Ie:

 

test.php


<?php
$status = "1";

If ($status == "1"){
echo '<img src="http://blaaaaa.com/1.png" />';
}else{
echo '<igm src="http://blaaaaa.com/2.png" />';
}
?>

 

Then if in a html file i refer to test.php instead of 1.png nothing happens.

 

Status.php should be something like

 

<?php
// tell the user's browser that it is an image
header("Content-type: image/png");

if($Status == "Offline")
{
$image = imagecreatefrompng("Offline.png");
}
else
{
$image = imagecreatefrompng("Online.png");
}


// and now... we display the image
imagepng($image);
imagedestroy($image);

?>

what does the resulting html source look like when you have tested each condition, and are both images in the location you have specified and the paths correct?

 

If you have already determined that a user is online/offline by by declaring a variable as 1 or 0 then displaying an image would be easy.

The problem with using

 

<?php
$status = "1";

If ($status == "1"){
echo '<img src="http://blaaaaa.com/1.png" />';
}else{
echo '<igm src="http://blaaaaa.com/2.png" />';
}
?>

 

And then using that as an image source, is that the above code is outputting in HTML format, not image format

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.