JohnOP Posted April 14, 2012 Share Posted April 14, 2012 I am creating a stream for my website similar to facebook's news feed where users can post to, add photos too ect. When a user uploads a photo it gets added to the photos table and a new row to the stream mysql_query("INSERT INTO photos VALUES ('','$id','$username','$photo','$time')"); mysql_query("INSERT INTO stream VALUES ('','$id','$username','$time','No comment','$photo','')"); Which displays the image on the stream fine but what i am looking to do is if the user uploads more images one after another instead of adding a new post to the stream for every picture i want to show all of the new pictures in one post like what Facebook does. I can't figure out how i would do this. Quote Link to comment https://forums.phpfreaks.com/topic/260917-user-stream/ Share on other sites More sharing options...
scootstah Posted April 14, 2012 Share Posted April 14, 2012 You're probably going to want to have a stream_id column in your photos table, so that you can link it to the appropriate row in the stream. Quote Link to comment https://forums.phpfreaks.com/topic/260917-user-stream/#findComment-1337293 Share on other sites More sharing options...
JohnOP Posted April 14, 2012 Author Share Posted April 14, 2012 Yes preferably i could make a stream_id in the table and check it against there recent posts but i can't update the row in the stream to show more images as the stream table only holds one column for a photo. I looked up using multiple values in one column but i seen it was looked upon. Quote Link to comment https://forums.phpfreaks.com/topic/260917-user-stream/#findComment-1337298 Share on other sites More sharing options...
xyph Posted April 14, 2012 Share Posted April 14, 2012 While you're looping through the results, have a variable track the user, time, or any other vars that help you decide whether to group the results or not. If the user doesn't change between loops, and the time is within, say, 2 minutes of the last row, then don't output the separator. I've done something *similar* in a recent post http://www.phpfreaks.com/forums/index.php?topic=357655.msg1690522#msg1690522 In that example, I check if the category ID has changed before outputting the category name/separator Quote Link to comment https://forums.phpfreaks.com/topic/260917-user-stream/#findComment-1337310 Share on other sites More sharing options...
JohnOP Posted April 14, 2012 Author Share Posted April 14, 2012 I see what you mean though how could i write "If two rows with time span of under 2 minutes that have the same id, username" within the while loop which gets all different users, post at the same time. Quote Link to comment https://forums.phpfreaks.com/topic/260917-user-stream/#findComment-1337351 Share on other sites More sharing options...
xyph Posted April 14, 2012 Share Posted April 14, 2012 Using a conditional statement. You'll have to be more specific with your questions, or attempt it yourself first. I'm unable to help you through every single step, it's a very involved process for a volunteer. My example shows how it could be done with a single condition Quote Link to comment https://forums.phpfreaks.com/topic/260917-user-stream/#findComment-1337358 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.