Please be patient with me with this question as I'm fairly new to PHP (apart from contact forms and login forms etc) but I really need some help relating to Arrays and data held in 2 separate tables. The scenario is that I am building an events section in a website & I am holding the data in an 'events' table:
event_id, event_name, event_time, etc, etc
I then have a table (event_followers) for followers of the events:
event_id | user_id
event_id | user_id
event_id | user_id
What i need to do is select all of the events that a particular user is following and show it as an array and then somehow get specific information about each of the events that is listed in the array/result. Any ways this can be done?
I'm sorry if this is basic php but as I said I'm pretty new to it. Thanks
Try this :
$query = mysqli_query("SELECT * FROM events
LEFT JOIN event_followers as fol ON event_followers.event_id = events.event_id
WHERE event_followers.user_id='".$user_id "'");
while($row = mysqli_fetch_assoc($query)){
print_r($row);
}
mysql
* functions are deprecated, so use mysqli_
* or PDO
, But I am not good at that so I written the code in mysql
.