/    Sign up×
Community /Pin to ProfileBookmark

Something small missing

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

[code=php] while ($list = mysql_fetch_array($result)) {
echo “{$list[‘file’]} “;
}[/code]

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

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 23.2007 — [code=php]
echo "<img src='{$list['file']}' alt=''>";
[/code]
Copy linkTweet thisAlerts:
@oo7mlauthorJan 23.2007 — Still doesn't work, i have:

[code=php] <?php
while ($list = mysql_fetch_array($result)) {
echo "<img src='{$list['file']}' alt=''>";
}
?>[/code]
Copy linkTweet thisAlerts:
@oo7mlauthorJan 23.2007 — Sorry it works on IE but not in firefox ..... Is there anyway around this to get it working on both
Copy linkTweet thisAlerts:
@NogDogJan 23.2007 — 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.:
[code=php]
echo "<img src='/site/uploaded_files/".basename($list['file'])."' alt=''>";
[/code]
Copy linkTweet thisAlerts:
@NightShift58Jan 23.2007 — 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?
Copy linkTweet thisAlerts:
@oo7mlauthorJan 23.2007 — [code=php] <td width=501>

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



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>
Copy linkTweet thisAlerts:
@NightShift58Jan 23.2007 — NogDog asked what code is being generated (resulting HTML source code).

The code NogDog posted works (here) with IE7 and FF2...
Copy linkTweet thisAlerts:
@oo7mlauthorJan 23.2007 — Just tried it there before i seen the last thread, works fine now, thanks so much guys, i really appreciate it, thanks again
×

Success!

Help @oo7ml spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...