Jump to content

Random Image


Jackthumper

Recommended Posts

Im Am Trying To Display A Random Image Every Time The Page Refreshs

i dont know if this will help???

<?php

/*

User Pets (user_pets.php)

*/

$rank_check = 1;
$page_title = "User Pets";
include "header.inc.php";

print $openHTML;

$array = fetch("SELECT * FROM user_pets2 WHERE id = '$id' AND game = '$game'");

if (!$array[id])
{
    die("<p align=center class=error>That is not a real pet</p>$closeHTML");
}

if ($array[pet_desc])
{
    $petNote = "<tr><td colspan=2><p align=center><font size=-1><i>$array[pet_desc]</i></font></p></td></tr>";
}

print "<center><table>$petNote<tr>
<td width=200>
";

$id = $array[id];
$getPet = fetch("SELECT * FROM pets2 WHERE id = '$array[species]' AND game = '$game'");
$getOwner = fetch("SELECT display_name,username FROM members2 WHERE id = '$array[owner]' AND game = '$game'");

$image = "pet_$getPet[id]";

if ($array[wearing] != 0)
{
    $findLook = fetch("SELECT * FROM pet_looks WHERE change_from = '$array[species]' AND item_name = '$array[wearing]'");

    if ($findLook[id])
    {
        $image = "pet2_$findLook[id]";
    }
}

$hunger = $array[$hunger];

$hungerLevel = $hungerArray[$hunger];

if (($array[hunger] > 10) OR ($array[hunger] < 0)) { $hungerLevel = "Unknown ($array[hunger])"; }

$percentHealth = ($array[current_hp] / $array[max_hp]) * 100;
if ($percentHealth > 0)
{
    $healthLine = "<font color=red>$array[current_hp]/$array[max_hp]</font>";
}
if ($percentHealth > 35)
{
    $healthLine = "<font color=orange>$array[current_hp]/$array[max_hp]</font>";
}
if ($percentHealth > 75)
{
    $healthLine = "<font color=green>$array[current_hp]/$array[max_hp]</font>";
}

ECHO <<<END

<br>
<CENTER><TABLE BGCOLOR="#$tableOutline" CELLSPACING=1 CELLPADDING=0 WIDTH=400>
   <tr>
   <td colspan=2 bgcolor=#$topAndBottomBG><font color=#$topAndBottomText><b>View Pet:</b></font></td></tr>
   <TR>
      <TD BGCOLOR=#$middleBG>
         <p>
    <font size=-1>
    Name: $array[name]<br>
    Level: $array[level]<br>
    Experience: $array[experience]<br>
    Next Level: $nextLevel[$id]<br>
    Health: <b>$healthLine</b><br>
    Strength: $array[strength]<br>
    Intelligence: $array[intelligence]<br>
    Speed: $array[speed]<br>
    Defense: $array[defense]<br>
    Hunger: $hungerLevel<Br>
    </font>
    </p>

    <p>
    <font size=-1>
    1-Player Wins: $array[one_p_wins]<br>
    1-Player Loses: $array[one_p_loses]
    </font>
    </p>

      </TD>
      <TD WIDTH=175 BGCOLOR=#FFFFFF>
         <p align=center>
    <img src=$base_url/images/user_images/opg_$game/pets/$image.gif border=1>
    <br><a href=view_pet.php?id=$array[id]&game=$game><b>$array[name]</b> the $getPet[name]!$petNote[$id]</a></P>    <p align=center>$attitude[$id]</p>
      </TD>
   </TR>
</TABLE>
</CENTER>

<p align=center><a href=user_profile.php?game=$game&user=$getOwner[username]>Back to $getOwner[display_name]'s Profile!</a></p>

END;

print "$closeHTML";

?>

Please Help Me

Jackthumper :)

Link to comment
Share on other sites

But how can i do that when its getting the images from a database

$getPet = fetch("SELECT * FROM pets2 WHERE id = '$array[species]' AND game = '$game'");
$getOwner = fetch("SELECT display_name,username FROM members2 WHERE id = '$array[owner]' AND game = '$game'");

$image = "pet_$getPet[id]";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.