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
Creating a Status Indicator (like ICQ)
Moderator: General Moderators
-
EverToDesign
- Forum Newbie
- Posts: 10
- Joined: Sat Oct 11, 2003 9:38 am
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">";
?>-
EverToDesign
- Forum Newbie
- Posts: 10
- Joined: Sat Oct 11, 2003 9:38 am
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?
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?
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,
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 . '">';
?>You could implement that wherever you would want the image to be.
Example:
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>