Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 72601

Re: How to display only the images loaded by a specific user?

$
0
0

You would ideally need to store the image names/numbers in a seperate table and associate the user_id with the image

 

So in your 'image' table you would have 3 columns:

 

image_id          user_id                     image_name

1                             10                              1234

2                              10                              8096

3                              5                                  6582

4                              7                                  8765

5                              7                                  6765

6                             10                                 9876

 

 

Above you see user_id 10 has uploaded 3 images, user_id 7 has uploaded 2 images and user_id_5 has uploaded 1 image

 

Then you would select the images from the 'images' table based on the user_id once they have signed in:

 

SELECT image_name FROM images WHERE user_id = 10

 

So when a user signs in to upload an image you would append the 'user_id' to a hidden form field :

 

<input type="hidden" name="user_id" value="<php echo $userInfo['user_id']; ?>" >

 

Then get the user_id and the image_name once the form is submitted to store in the information in the database table  'images'

$user_id = $_POST['user_id'];
$image_name= $_POST['image_name'];
INSERT INTO images (user_id, image_name) VALUES ('$user_id' , '$image_name')

Viewing all articles
Browse latest Browse all 72601

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>