Sorrow Posted August 3, 2008 Share Posted August 3, 2008 Hi there, I am trying to load the image link from the database to have an image displayed but the image is not loading at all. <?php include 'opendb.php'; $currIndex = $_GET['index']; $query = "SELECT * FROM reviews where m_index = $currIndex"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $Pic = "{$row['m_Link']}"; echo "{$row['m_Title']} <p>". "{$row['m_Review']} <br> <img src='$Pic'>"; } mysql_close($con); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/ Share on other sites More sharing options...
papaface Posted August 3, 2008 Share Posted August 3, 2008 Shouldn't it be: <?php include 'opendb.php'; $currIndex = $_GET['index']; $query = "SELECT * FROM reviews where m_index = $currIndex"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $Pic = "{$row['m_Link']}"; echo "{$row['m_Title']} <p>". "{$row['m_Review']} <br> <img src='{$row['m_Link']}'>"; } mysql_close($con); ?> </body> </html> ? Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/#findComment-606869 Share on other sites More sharing options...
unkwntech Posted August 3, 2008 Share Posted August 3, 2008 Try this: <?php include 'opendb.php'; $currIndex = $_GET['index']; $query = "SELECT * FROM reviews where m_index = $currIndex"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row['m_Title'] . "<p>". $row['m_Review'] . "<br><img src='" . $row['m_Link'] . "'>"; } mysql_close($con); ?> </body> Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/#findComment-606872 Share on other sites More sharing options...
Sorrow Posted August 3, 2008 Author Share Posted August 3, 2008 Thanks for your reply guys but it is not working. I don't know if this would help but the link that is saved in the db is not from the server of my hosting it is a link from an external website. Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/#findComment-606894 Share on other sites More sharing options...
unkwntech Posted August 3, 2008 Share Posted August 3, 2008 Did you try my suggestion, and what is it out puting? Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/#findComment-606901 Share on other sites More sharing options...
Sorrow Posted August 3, 2008 Author Share Posted August 3, 2008 yes i tried it and nothing shows up not even a broken picture sign Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/#findComment-607009 Share on other sites More sharing options...
trq Posted August 3, 2008 Share Posted August 3, 2008 Can you show us what the relevent generated html looks like? eg; right click and view source. Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/#findComment-607012 Share on other sites More sharing options...
Sorrow Posted August 4, 2008 Author Share Posted August 4, 2008 here it is <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Web Of The Living Dead</title> </head> <body bgcolor="#000000" text="#FF0000" link="#FF0000" vlink="#FF0000"> 28 days later <p>Even though it's only a single disc, the 28 Days Later DVD includes a lot of very interesting features, including the alternate ending that was shown after the end of the film a couple months into its theatrical run. It's much bleaker, as director Danny Boyle and writer Alex Garland say in their optional commentary. Another alternate ending is almost the same as the theatrical ending but slightly less happy. Most interesting is the "radical" alternate ending that takes an entirely different path midway through the film. It wasn't filmed, however, so Boyle and Garland narrate the action over storyboards, and it's a surprisingly engrossing 11 minutes. Boyle and Garland also did a commentary track for the film, and they talk about how they were able to get the shots of deserted London and why they used the ending they did. There are also six very watchable deleted scenes, and Boyle and Garland's comments range from "great sequence" to "a disgrace." Slightly less relevant is a 24-minute documentary that spends its first 10 minutes on the real-life threat of infectious diseases before recapping the film and discussing such elements as the use of digital video and the boot camp the actors had to attend. If you need any further proof that the DVD was a labor of love, even the stills galleries have commentaries. --David Horiuchi <br> <img src='http://rcm-ca.amazon.ca/e/cm?t=weofthlide-20&o=15&p=8&l=as1&asins=B000QTD05C&fc1=FD0202&IS2=1<1=_top&lc1=0000FF&bc1=FFFFFF&bg1=000000&f=ifr'></body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/#findComment-607045 Share on other sites More sharing options...
coder500 Posted August 4, 2008 Share Posted August 4, 2008 The following code will work while($row = mysql_fetch_array( $result )) { echo $row['name']; echo "<img src='$row[image_link]'><br>"; } Let me know the result... Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/#findComment-607222 Share on other sites More sharing options...
Andy-H Posted August 4, 2008 Share Posted August 4, 2008 <?php include 'opendb.php'; $currIndex = mysql_real_escape_string($_GET['index']); $query = "SELECT * FROM reviews where m_index = '$currIndex'"; $result = mysql_query($query)or die(mysql_error()); while($row = mysql_fetch_array($result, "MYSQL_ASSOC")){ $Pic = $row['m_Link']; $Title = $row['m_Title']; $Review = $row['m_Review']; echo $Title . "<p>" . $Review . " <br /><img src=\"" . $Pic . "\" /></p>"; } mysql_close($con); ?> </body> </html> Does that work? Quote Link to comment https://forums.phpfreaks.com/topic/117969-image-link-from-db/#findComment-607223 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.