So I have a tv show website and I created custom lists where you can add whatever tv shows you want.
There is one table called lists (with user_id, list_title) and another table called show_lists which contains (list_id, show_id).
So my PHP is there:
<?php
$findlistsq = $conn->prepare('SELECT * FROM show_lists, shows, lists
WHERE lists.user_id = :user_id AND
lists.list_id = show_lists.list_id AND
shows.id = show_lists.show_id');
$findlistsq->execute(array(':user_id' => 2));
$listscount = $findlistsq->rowCount();
echo $listscount;
$list = array();
while ($listarray = $findlistsq->fetch()) {
$list[$listarray['list_title']][$listarray['name']] = $listarray;
}
?>
<?php
foreach ($list as $key => $show) {
echo $key; //echo title of list
foreach ($show as $key => $value) {
echo $value['name']; //echo tv shows
;
}
}
?>
Basically, I create an array to join a list to its tv shows, display the title of the list and whatever it contains and so on. My question is: I want to display the list only if there is more than 3 shows (at least 3 different $value).
Can anybody tell me how I could do that ? Thanks!!
Edit: Also, there is slight chance that I might have overcomplicated this. Let me know if I did.