Jump to content

[SOLVED] Can I open an image this way?


Joefunkx

Recommended Posts

I am using php to perform a query on a mysql table and then display the results on a page. Next to each result, i want to be able to display an image that pertains to that specific result. I do not want to upload the  images into the table due to space issues. Essentially, each result will have a 5 digit id variable that i am trying to name the images. So, for example, result a will have id 11111 so it would link to image 11111.jpg, result b will have id 22222, so it would link to image 22222.jpg. I tried the following without any luck-

 

<IMG SRC="<?yourfield?>.jpg">

 

where yourfield is equal to the 5 digit number mentioned above.. the only thing i get when the page is displayed is an empty image that is trying to point to ".jpg". Any thoughts on this? Thanks guys!

Link to comment
Share on other sites

Before trying to display your image, you need to debug your code/php to make sure you're pulling the value correctly from the database. You also need to make sure you're specifying the correct image path.

 

<?php

  $query = $db->query("SELECT * FROM usrinfo WHERE id = '$id'");
  $usrinfo = $db->fetch_array($query);

  echo'<img src="images/'.$usrinfo[uid].'jpg" alt="image info" />';

?>

 

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.