I’m creating a social network. I want to have a user be able to subscribe to people. In theory, when a user clicks the subscribe button, PHP would add that user’s ID to an array in their MYSQL listing under the column “subscribed-to”. Now, I want to have a news feed style home page. I want to know, if I pull the “subscribed-to” data via PHP, how could I show only the posts (also in a MYSQL table) of the people the user is subscribed to?
Share
Use UNION to combine all the posts from different tables, then use the “IN” clause to get all the userID’s you want to follow based on the current userID:
Example:
If you run the query thru mysql_fetch_array() it’ll return something like this:
You need to make sure that you have the same amount of columns in each SELECT statement everytime you call “UNION”, otherwise it will not work. You can /fake/ columns as I have done with the
typecolumn above.