I've been trying to fiddle with this code to no avail, my goal is to... well basically what the title says, post the individual images, but all the code does is post everything from the folder and that's not what I want... Here is the code:

and does it matter where I put the SQL query? (PHP noob here, sry) and if that's not the right spot, where should I put it?

StarLion
—
2012-05-09T12:32:04Z —
#4

It wasnt a question of positioning so much as "what is it actually DOING?" It doesnt appear to have any use - as soon as the next iteration of the loop is called, your query re-executes itself, and...still does nothing with the result.

If you need the information from the query later on in the script, pull the query out of the loop so you only run it once, and still have the result available.

When you say 'post the individual images'... what do you mean? This script is clearly designed to post all image files in a directory.

Hikaru_Kagi
—
2012-05-09T22:12:49Z —
#5

Well I guess that's idiotic of my part that SQL statement actual refers to another code that I haven't posted lol

and when I say post the individual images, I'm wanting to be able to define a variable that can loop through all the images like have the template variable 'IMG' and so I can put in the HTML template with the description and name, and keep looping until no more images are available, I don't want to post all the images at the same time. I hope that makes sense.

StarLion
—
2012-05-10T13:01:52Z —
#6

Okay. Think we need to adjust some stuff.

You want the name, description, and image all tied together. So, lets put them all together.

I assume that the 'image' field in the sql table holds the file name of the image file.

after the colon is where I see it happening, but i take it out, it just screws up entirely (very confused right now)

StarLion
—
2012-05-11T13:11:18Z —
#12

It's a Ternary condition.

(ifcondition) ? trueresult : falseresult;

It's evaluating (file_exists($dir.$row['image']) as False. Which, if $row['image'] contains the full path, is the correct result. It should be (file_exists($row['image'])instead.

Hikaru_Kagi
—
2012-05-11T13:25:11Z —
#13

Well I'm starting to understand it now, but I still can't get the images to show up, and when I put the file path into the browser URL, the image will show up there, but not for the site, and I took out that first line of code, since you said $dir wasn't needed anymore, I hope that didn't mess anything up...

StarLion
—
2012-05-11T13:34:40Z —
#14

Is it still sending Image Missing out, instead of the image?

Hikaru_Kagi
—
2012-05-12T00:09:49Z —
#15

yep, still getting that missing.jpg

Hikaru_Kagi
—
2012-05-13T07:14:27Z —
#16

Couldn't edit the post, but I finally got it working, the file path in the database was wrong lol, I had it as localhost/images/, when it was supposed to be just images/ but thank you for all your help StarLion, couldn't have done without you