Page 1 of 1
Creating a Status Indicator (like ICQ)
Posted: Sat Oct 11, 2003 4:35 pm
by EverToDesign
Hey, heres the problem.
from a control panel a member can change their status Available/Not available/busy which is put into a MySQL Table with their record.
Now i need it so an .html page can parse this information and return an appropriate icon like ICQ Status Indicators
Ex- if a person was offline an image should appear that would represent them being offline, if online one for online if busy one for busy.
How do I go about doing this? I looked at ICQ's code but its just an IMG SRC Tag to a script not an actual image.
Any ideas or pointers to tutorials for this?
Thanks in advance
Posted: Sat Oct 11, 2003 5:17 pm
by nigma
Code: Select all
<?php
/* the variable "status" should be set to whatever the users current status is */
switch ($status)
{
case 'away' :
$icon = "AWAYICON.jpg";
break;
case 'busy' :
$icon = "BUSYICON.jpg";
break;
default :
$icon = "DEFAULTICON.jpg";
break;
}
echo "<img src="$icon">";
?>
Posted: Sat Oct 11, 2003 5:24 pm
by EverToDesign
Thanks for the quick code snippet but just where would I implement that? I need to have the status show up on a .html page in an img src tag preferbly.
Would I be bale to link it to a page ex <img src="
http://www.sitehere.com/status.php">
and then have the switch code there where it simply echos out the img src tag you showed, would that make the image appear?
Posted: Sat Oct 11, 2003 5:37 pm
by evilMind
Yes you can link it to a php page by using <img src="generateIconStatus.php" /> However. You will have to pass varialbes to the "image" so you would then call it by <img src="generateIconStatus.php?status=away" />.
In the php file (generateIconStatus.php in this example) You will need to use the header() function to send a Content Type for the image you will be displaying (ie, header('Content-Type: image/jpeg');).. So it could be something that incorporates what nigma said, but with the addition of the header() call.
eg,
nigma wrote:
Code: Select all
<?php
/* the variable "status" should be set to whatever the users current status is */
switch ($status)
{
case 'away' :
$icon = "AWAYICON.jpg";
break;
case 'busy' :
$icon = "BUSYICON.jpg";
break;
default :
$icon = "DEFAULTICON.jpg";
break;
}
/* See below */
?>
Code: Select all
header('Content-Type: image/jpeg');
echo '<img src="' . $icon . '">';
?>
Posted: Sat Oct 11, 2003 10:20 pm
by nigma
You could implement that wherever you would want the image to be.
Example:
Code: Select all
<div id="status">
<?php
/* the variable "status" should be set to whatever the users current status is */
switch ($status)
{
case 'away' :
$icon = "AWAYICON.jpg";
break;
case 'busy' :
$icon = "BUSYICON.jpg";
break;
default :
$icon = "DEFAULTICON.jpg";
break;
}
?>
</div>