Click to See Complete Forum and Search --> : Something small missing


oo7ml
01-23-2007, 10:15 AM
I table that randomly selects an entry from a certain field my mySQL database

The field hold the directory for image uploads (C:/wamp/www/site/uploaded_files/1169563553.jpg)

So the page selects the fieldname contents and prints them out into the table cell

My question is, how can i get the image itself to be displayed ???

This is the code i am using to get the image directory from the database

while ($list = mysql_fetch_array($result)) {
echo "{$list['file']} ";
}

It is working as far as printing the directory into the cell but how do i get the image itself to show, where do i put the image tags on the ablove code or is that the correct way of doing this at all

NogDog
01-23-2007, 10:19 AM
echo "<img src='{$list['file']}' alt=''>";

oo7ml
01-23-2007, 11:08 AM
Still doesn't work, i have:

<?php
while ($list = mysql_fetch_array($result)) {
echo "<img src='{$list['file']}' alt=''>";
}
?>

oo7ml
01-23-2007, 11:22 AM
Sorry it works on IE but not in firefox ..... Is there anyway around this to get it working on both

NogDog
01-23-2007, 11:22 AM
What does the HTML source code look like that it generates? I'm guessing that you'll need to grab the file name (perhaps with the basename() function) and append it to a full URL string or a document root path, e.g.:

echo "<img src='/site/uploaded_files/".basename($list['file'])."' alt=''>";

NightShift58
01-23-2007, 11:30 AM
If the path/to/file is wrong, then it wouldn't/couldn't work for neither IE nor FF. The problem has to lie elsewhere... no?

oo7ml
01-23-2007, 11:37 AM
<td width=501>

<?php
while ($list = mysql_fetch_array($result)) {
echo "<img src='{$list['file']}' alt=''>";
}
?>
</td>


This is the exact code i have, WHAT could it be, it's really strange, is it just one of thos differences between FF and IE or am i doing something wrong. Anyone any idea what could be causing it

The HTML code that is generated is:

<td width=501 >

<img src='C:/wamp/www/site/uploaded_files/1169570533.jpg' alt=''>
</td>

NightShift58
01-23-2007, 11:47 AM
NogDog asked what code is being generated (resulting HTML source code).

The code NogDog posted works (here) with IE7 and FF2...

oo7ml
01-23-2007, 11:51 AM
Just tried it there before i seen the last thread, works fine now, thanks so much guys, i really appreciate it, thanks again