Welcome to WebmasterWorld Guest from 107.20.34.173

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Help adding image to php?

want to add image instead of text.....

     

Par5Golf

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

10+ Year Member



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

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

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

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

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month