Member Avatar for OldDeveloper01

Im creating a community website and have a little problem working out what my if statment should look like.

there is a default profile image and the one that is stored in the users directory.

so basically i want to display the image which is in the users directory, but if there isnt then display the defualt image. the defualtimage name is saved to the profimage row when the user registers.

Users directory:
users/$userid/images/$profimage

defualt pic
images/$profimage

i have one variable $profimage which completes filepath which basically grabs the filename from the database

i don't know where to start displaying one or the other. Any help would be great. struggling to think.

Thanks

//keep the whole path including the filename inside the $filename
//this may be users/$userid/images/filename

if (file_exists($filename)) {
    $image = $filename;
} else {
    $image = $default_image;
}

Im not sure if this is what you need??

for better solution you store path (url) in database and image file in folder

when you fetch record from database that time check url exis or not them check file exist or not

it better solution

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.