Welcome to WebmasterWorld Guest from 54.163.166.22

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Help adding image to php?

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

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

New User

10+ Year Member

joined:Oct 25, 2002
posts:20
votes: 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

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

Senior Member from US 

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

joined:Mar 31, 2002
posts:7575
votes: 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\">";

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

Administrator

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

joined:July 24, 2001
posts:15755
votes: 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.
5:48 am on Dec 2, 2002 (gmt 0)

New User

10+ Year Member

joined:Oct 25, 2002
posts:20
votes: 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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members