Redlightpacket Posted March 18, 2009 Share Posted March 18, 2009 Here is my code right here. I need some help with displaying the image in the code. I might be having a bug. $query = "SELECT * FROM picture_tb"; $result = mysql_query($query) or die("Query failed: " . mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo'<table border="1"> <tr> <td>';echo $row["id"];echo'</td> <td><IMG SRC="';echo'file:///C:/wamp/www/';$row['picture'];echo'">';echo'</td> <td>';echo $row["title"]; echo'</td> <td>';echo $row["desc"]; echo'</td> </tr> </table> '; } ////////////////////////////////////////////////////////code] Quote Link to comment https://forums.phpfreaks.com/topic/150033-solved-dont-know-how-to-display-a-image-in-php/ Share on other sites More sharing options...
gijew Posted March 18, 2009 Share Posted March 18, 2009 Try replacing <td><IMG SRC="';echo'file:///C:/wamp/www/';$row['picture'];echo'">';echo'</td> with <td><IMG SRC="'C:/wamp/www/' . $row['picture'] . '"></td> Quote Link to comment https://forums.phpfreaks.com/topic/150033-solved-dont-know-how-to-display-a-image-in-php/#findComment-787940 Share on other sites More sharing options...
Stephen68 Posted March 18, 2009 Share Posted March 18, 2009 Hello I'm not sure about weather you should have those semi's and echo's that way.... I could be wrong though. <td>';echo $row["id"];echo'</td> I have not seen code laid out this way but that doesn't mean it is wrong either try $query = "SELECT * FROM picture_tb"; $result = mysql_query($query) or die("Query failed: " . mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo'<table border="1"><tr><td>'; echo $row["id"]; echo'</td><td><IMG SRC="'; echo "file:///C:/wamp/www/".$row['picture']."\"></td><td>"; echo $row["title"]; echo'</td><td>'; echo $row["desc"]; echo'</td></tr></table>'; } ////////////////////////////////////////////////////////code] hope this helps in some way Quote Link to comment https://forums.phpfreaks.com/topic/150033-solved-dont-know-how-to-display-a-image-in-php/#findComment-787943 Share on other sites More sharing options...
Redlightpacket Posted March 18, 2009 Author Share Posted March 18, 2009 I'll try what yall are talking about Quote Link to comment https://forums.phpfreaks.com/topic/150033-solved-dont-know-how-to-display-a-image-in-php/#findComment-787944 Share on other sites More sharing options...
Redlightpacket Posted March 18, 2009 Author Share Posted March 18, 2009 I changed this around a little bit and it worked I changed file:// to http:// echo "http://localhost/".$row['picture']."\"></td><td>"; but thanks for the help everybody Quote Link to comment https://forums.phpfreaks.com/topic/150033-solved-dont-know-how-to-display-a-image-in-php/#findComment-787969 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.