Question

I have a photo upload script. In general everything is similar to general concepts. Also it is similar to Facebook's profile image logic. Differently I set user's profile picture by latest uploaded image. More clearly;

Steps:

  1. user uploads profile picture
  2. he/she can see the picture in some criteria comes from Mysql : ORDER BY add_date DESC so newest picture can fetched by php

  3. Also I have a delete image button. If I use Mysql's DELETE keyword because of ORDER BY DESC newest picture is changing.

  4. How can I set default picture after I click delete image button


enter image description here

as you can see from picture user 5 has added 3 different images in three different time. mysql query is : SELECT path FROM profile_image WHERE user_id = ".$_SESSION['SES_USER_ID']." ORDER BY add_date DESC;" showing picture to user and for fetching. earliest date is user's active profile image. (June 28 )

if I delete June 28, June 27's photo will be active profile image, not the default profile image.

How can I set default image?

Était-ce utile?

La solution

Have another table with fields userid, isset - ( with default value of 1 for all users)

If user clicks the remove profile pic( wishes to have the default pic) , change the value in isset to 0 for the respective user.

Check this table everytime before fetching the latest image from the profile pics table.

Alternatively you can have the isset field in the profile pics table itself. This would require you to change the isset value of every occurrence of the user's profile pic if he wishes to have the default pic.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top