Jump to content

User stream


JohnOP

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.