Jump to content

PHP and displaying images


mrkfox

Recommended Posts

Hi I am trying to display some images on a page using PHP. The image url (/images/products/imagename.jpg) is stored in a database. How would i go about displaying the image on my html page?

 

Thanks in advance

Link to comment
Share on other sites

The actual images are stored in /images/products. The database only stored the image location for example: /images/products/imagename.jpg

 

Forgot to say i have multiple images in my database and i would like them all displayed on my page.

Link to comment
Share on other sites

I've managed to get the data from the database and have assigned it to some variables. This is what I'm trying to use to display all of it:

 

echo "<b>$name</b><br>$description<br>genre<br>£$price<br>$stock<br><img src='$image' /><br>";

 

everything gets displayed successfully except for the image. Any help?

Link to comment
Share on other sites

Figured it out finally after 2 hours. I had the paths saved in my database as /images/products/image.jpg and i had to have them as images/products/image.jpg. All i had to do was take the slash from the start of the path.

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.