mrkfox Posted May 9, 2009 Share Posted May 9, 2009 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 Quote Link to comment Share on other sites More sharing options...
gevans Posted May 9, 2009 Share Posted May 9, 2009 Is the image stored in a database, or is the image filename stored in the database? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 gevans, he said the image url is stored in the database. Run a SQL that gets the image and just write it out. Quote Link to comment Share on other sites More sharing options...
mrkfox Posted May 9, 2009 Author Share Posted May 9, 2009 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. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 Then run a SQL that gets them all. Quote Link to comment Share on other sites More sharing options...
mrkfox Posted May 9, 2009 Author Share Posted May 9, 2009 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? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 Can you verify the URL for the images are correct? Quote Link to comment Share on other sites More sharing options...
mrkfox Posted May 9, 2009 Author Share Posted May 9, 2009 If i take out the image tags the image url gets displayed correctly. I have triple checked that the images are in the correct location and the datbase contains the correct paths to the images. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 Can you post the output of that echo? Quote Link to comment Share on other sites More sharing options...
mrkfox Posted May 9, 2009 Author Share Posted May 9, 2009 Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 No I mean the HTML. Thanks! Quote Link to comment Share on other sites More sharing options...
mrkfox Posted May 9, 2009 Author Share Posted May 9, 2009 I basically have a button in a form on the simplest html page possible which when clicked goes to a displayproducts.php and then the data gets displayed. Quote Link to comment Share on other sites More sharing options...
gevans Posted May 9, 2009 Share Posted May 9, 2009 When you're on the page, right click and hit 'view source' and post the html! Quote Link to comment Share on other sites More sharing options...
mrkfox Posted May 9, 2009 Author Share Posted May 9, 2009 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. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 -.- that was the whole point I asked you for the HTML. Quote Link to comment Share on other sites More sharing options...
mrkfox Posted May 9, 2009 Author Share Posted May 9, 2009 thanks for ya help i guess it's all good now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.