sjones Posted March 7, 2006 Share Posted March 7, 2006 Hello, I am trying to write a script that will allow the user to view vendors, select their name, hit the view button and see their image. I have everything done accept the image does'nt show up in the browser.[a href=\"http://www.uswebproducts.com/country_savings/view_coupon.php\" target=\"_blank\"]Click here to view[/a]The script is below, If someone can tell me where I went wrong, I would appreciate it.<?phpecho "Testing the view_coupon.php page!";include ('connections/mysql_connect.php'); if (!isset($_POST['submit'])) { echo "<form method='post' action='view_coupon.php'> <select name='vendor_id'> <option>- Please select one -</option>\n"; $qry = mysql_query("SELECT * FROM vendors;"); while($rows = mysql_fetch_assoc($qry)) { echo "<option value='".$rows['vendor_id']."'>".$rows['vendor_name']."</option>\n"; } echo "</select> <input name='submit' type='submit' value='View'> </form>"; }else{ if (isset($_POST['submit'])) { $image_query ="SELECT file_name FROM uploads WHERE uploads.vendor_id = ('".$_POST['vendor_id']."');"; $result = mysql_query($image_query); $record = mysql_fetch_row($result); echo "<table align='center' width='90%'> <tr> <td><img src='http://uswebproducts.com/country_savings/uploads/$record'> </td> </tr> </table>"; } }?> Quote Link to comment https://forums.phpfreaks.com/topic/4379-having-troubles-image-does-not-show-up/ Share on other sites More sharing options...
dcro2 Posted March 7, 2006 Share Posted March 7, 2006 [!--quoteo(post=352656:date=Mar 7 2006, 05:33 PM:name=sjones)--][div class=\'quotetop\']QUOTE(sjones @ Mar 7 2006, 05:33 PM) [snapback]352656[/snapback][/div][div class=\'quotemain\'][!--quotec--]$record = mysql_fetch_row($result);//...<td><img src='http://uswebproducts.com/country_savings/uploads/$record'>[/quote]mysql_fetch_row returns an array, that's why the image displayed is:"http://uswebproducts.com/country_savings/uploads/Array"Use $record[0...1...2...etc] according to field orderIt would be better to use mysql_fetch_array or mysql_fetch_assoc in your case. Quote Link to comment https://forums.phpfreaks.com/topic/4379-having-troubles-image-does-not-show-up/#findComment-15204 Share on other sites More sharing options...
sjones Posted March 8, 2006 Author Share Posted March 8, 2006 This is the correction that I came up with it works very well. Thanks for the replyelse{ if (isset($_POST['submit'])) { $image_query ="SELECT file_name FROM uploads WHERE uploads.vendor_id = ('".$_POST['vendor_id']."');"; $result = mysql_query($image_query); while ($record = mysql_fetch_row($result)) { for ($i = 0; $i < count($record); $i++) { echo "<table align='center' width='90%'> <tr> <td><img src='http://uswebproducts.com/country_savings/uploads/$record[$i]'> </td> </tr> </table>"; } } } } Quote Link to comment https://forums.phpfreaks.com/topic/4379-having-troubles-image-does-not-show-up/#findComment-15249 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.