Rommeo Posted November 26, 2011 Share Posted November 26, 2011 I have some thousands of photos about nature I ll let visitors/members to see them one by one, but I dont want to show them the same photo again after they visit 1 week later How can I do this ? What I think as a solution is; For members; I can store the ids (like "everest01") of the photos that member has visited , and show user the most visited photos that he/she has not see for next visit. But what I m wondering is, how will I take the photos from DB ? select * from photos WHERE id not in ( $thousandsofvisitedphotoids ) ?? I m stuck here ? For visitors ( not members ) ; I can set a cookie that keeps the ids of visited photos.. when visitor visits the website again, I take the cookie and sent to $thousandsofvisitedphotoids and make a query again ? I m stuck here, How you guys do this ? what's the logic of this ? Quote Link to comment https://forums.phpfreaks.com/topic/251830-visited-photos/ Share on other sites More sharing options...
Laash Posted November 26, 2011 Share Posted November 26, 2011 For members, create an sql table that will contain a user's id + an image id, then select all the images for for that user that does not appear in this table. For non-members, create a cookie and fill it with an array of the images' ids, then check on every image load if the img id is located in your cookie's array of viewed images. Good luck! Quote Link to comment https://forums.phpfreaks.com/topic/251830-visited-photos/#findComment-1291380 Share on other sites More sharing options...
Rommeo Posted November 27, 2011 Author Share Posted November 27, 2011 For members, create an sql table that will contain a user's id + an image id, then select all the images for for that user that does not appear in this table. For non-members, create a cookie and fill it with an array of the images' ids, then check on every image load if the img id is located in your cookie's array of viewed images. Good luck! For members; there will be thousands of photos, and thousands of members so there will be millions of rows ( combination table of userid and photoid) , by a select query and taking the ids, and another select query for taking except those ids ( to print non visited photos ), will not it take time processing the query ? Quote Link to comment https://forums.phpfreaks.com/topic/251830-visited-photos/#findComment-1291564 Share on other sites More sharing options...
Rommeo Posted November 28, 2011 Author Share Posted November 28, 2011 any other ideas ? Quote Link to comment https://forums.phpfreaks.com/topic/251830-visited-photos/#findComment-1291896 Share on other sites More sharing options...
litebearer Posted November 28, 2011 Share Posted November 28, 2011 rough idea... add viewed field to user table. field is long text. field contains and array of viewed pic ids. when user signs in load viewed field into an array. then only display pics that are NOT in that array Quote Link to comment https://forums.phpfreaks.com/topic/251830-visited-photos/#findComment-1291901 Share on other sites More sharing options...
Pikachu2000 Posted November 28, 2011 Share Posted November 28, 2011 Storing more than one value in a field is not good solution, especially when those values will be compared against individually. Although I don't really see the point of what you're doing, you should store the photos seen already in a separate table. The id of the photos should be the PK index of the photo rather than the name, too. Quote Link to comment https://forums.phpfreaks.com/topic/251830-visited-photos/#findComment-1291919 Share on other sites More sharing options...
Rommeo Posted November 29, 2011 Author Share Posted November 29, 2011 Storing more than one value in a field is not good solution, especially when those values will be compared against individually. Although I don't really see the point of what you're doing, you should store the photos seen already in a separate table. The id of the photos should be the PK index of the photo rather than the name, too. but there will be thousands of users+visitors(not member) and photos, in that table there will be millions of rows (combination) visitedphotosTable userid | photoid 3 -------- 5 3 -------- 6 2 -------- 5 . . . I think there will be a delay while processing the query, wont there ? Quote Link to comment https://forums.phpfreaks.com/topic/251830-visited-photos/#findComment-1292094 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.