Jump to content

Having troubles - image does not show up.


sjones

Recommended Posts

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.

<?php
echo "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>";
}
}

?>
Link to comment
Share on other sites

[!--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 order

It would be better to use mysql_fetch_array or mysql_fetch_assoc in your case.
Link to comment
Share on other sites

This is the correction that I came up with it works very well. Thanks for the reply

else{
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>";
}
}
}
}
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.