I am having trouble with something that I know is probably really simple:

I have a bunch of photos in a profile image folder. I want to call the image based on the id of the folder like this main-$id.jpg. I need to know the PHP that can do that...

Thank You

Recommended Answers

All 4 Replies

do you save your image in your database or folder?

The images are all in a folder. When they are uploaded by a member it creates a small version and large version in the same folder main-id and mainl-id. id is equal to a number

You can do that but i will advice you to store your paths in DB.
As folder grows, sorting becomes a very big issue.

1. You must have a very logical naming for your images. eg. the big image named big2233.png and the small one sm2233.png. ID.

2.In this case you can go to the image folder and request for the images but you still must have something that connects this image to a USER/PERSON.


Give some more info ok?.
post your code. ;)

<?php
            if (file_exists("profileimages/main-$id.jpg")) {
                echo "<img src=\"profileimages/mainl-$id.jpg\">";
            } else {
                echo "<img src=\"images/default.png\">";
            }
            ?>

Ok if i am correct this code is used to pull the image file from a folder
and display it as the main profile image. This works fine. So how can I make
this work for me to post the thumb into the members account page. Or am I way
off with this code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.