Could someone please help me with my code, I can’t figure out how to display my image.
First off: I have a database table named: km_monsters. Fields include Id, name, stats, and images. I have the images field path directed to my images folder. The images themselves are not stored in the database. The images are good because i can manually make them appear with: print “<center><img src=’images/coyote.jpeg’></center>”;
The first part of the code works and gives me a random monster, and prints out the name of the monster.
But the second part, I cannot figure out on how to get the random monsters image to appear along with it.
[code=php]{
$monstername=$_POST[‘monstername’];
$monstername=strip_tags($monstername);
$selmonster=”SELECT * from km_monsters where `id`>= RAND() * (SELECT MAX(`id`) FROM km_monsters) LIMIT 1″;
$selmonster2=mysql_query($selmonster) or die (“Cannot find Animal”);
$selmonster3=mysql_fetch_array($selmonster2);
if (!$selmonster3)
{
print “There is not an animal of that name”;
}
else
{
print “<center>You see a $selmonster3[name]!</center><br>”;
$monsterimages=$_POST[‘monsterimages’];
$monsterimages=strip_tags($monsterimages);
$selmonster=”SELECT * from km_monsters where `images`=’$monsterimages'”;
$selmonster2=mysql_query($selmonster) or die (“Cannot find Image”);
$selmonster3=mysql_fetch_array($selmonster2);
$src=”images/$selmonster3[images]” . “.jpeg”;
print “<br><center><img src=$src></center>”;
}
Any help would be greatly appreciated!