homepage Welcome to WebmasterWorld Guest from 54.227.182.191
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Help adding image to php?
want to add image instead of text.....
Par5Golf




msg:1252828
 3:57 am on Dec 1, 2002 (gmt 0)

I am trying to add an image insted of text....here is the code for the text....


$streakwins = $row["streakwins"];
$streaklosses = $row["streaklosses"];

if ($streakwins >= $hotcoldnum) {
$color = "#FF0000";
$text = "hot";
}
else if($streaklosses >= $hotcoldnum) {
$color = "#0080FF";
$text = "cold";
}
else {
$color = "#FFFFFF";
$text = "";
}

and this is the images i want to add instead of the text?


<img src="/images/hot.gif">

<img src="/images/cold.gif">

any help would be nice....
Thanks
Eric

 

lorax




msg:1252829
 5:22 am on Dec 1, 2002 (gmt 0)

To set the var you'd simply write:

if ($streakwins >= $hotcoldnum) {
$color = "#FF0000";
$text = "hot";
$pic = "hot";
}

and then echo the image file where needed as

echo "<img src=\"/images/".$pic.".gif\">";

jatar_k




msg:1252830
 6:57 am on Dec 1, 2002 (gmt 0)

depending on where it is located you can also drop out of php and put the image tag right there or use echo/printf to output the proper image in that spot.

Par5Golf




msg:1252831
 5:48 am on Dec 2, 2002 (gmt 0)

yes that worked great thanks....one more question...:)

if i want to add an image to the #1 rank what diffrent tables to i have to make....for this to work....


<td><?=$Members->a['member_rank']?>
<td valign="middle"><A href="mailto:<?=$Members->a['member_email']?>"><?=$Members->a['member_name']?></a> <?

if($streak > 5)
{
?><img src="/images/hot.gif"><?
} elseif($streak < -5) {
?><img src="/images/cold.gif"><?
}

if($Members->a['member_was1st'])
{
?> <img valign="absmiddle" src="/images/no1.gif"> <?
}

i have a ranking system using this form and i want to use it with this one


$row = mysql_fetch_array($result);

$name = $row["name"];
$mail = $row["mail"];
$icq = $row["icq"];
$aim = $row["aim"];
$country = $row["country"];
$wins = $row["wins"];
$losses = $row["losses"];
$points = $row["points"];
$games = $row["games"];
if ($games <= 0) {
$percentage = 0.000;
}
else {
$percentage = $wins / $games;
}
$penalties = $row["penalties"];
$pen = $penalties;
if ($pen >= 5) {
$penplayer = "*****";
}
if ($pen >= 4) {
$penplayer = "****";
}
else if($pen >= 3) {
$penplayer = "***";
}
else if($pen >= 2) {
$penplayer = "**";
}
else if($pen >= 1) {
$penplayer = "*";
}
else {
$penplayer = "";
}

if ($streakwins >= $hotcoldnum)
{
$color = "#FF0000";
$text = '<img src="/images/hot.gif">';
}
elseif($streaklosses >= $hotcoldnum)
{
$color = "#0080FF";
$text = '<img src="/images/cold.gif">';
}
else
{
$color = "#FFFFFF";
$text = "";
}

Not sure what diffrent tables i need to make....if you have an idea and some time any help would be good

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved