0
I have 2 tables one of users and another of subscribers, I have an Internet that sends to the table of subscribers the email of the user who registered and the name of the channel
1st users
id | usuario | meucanal
1 | [email protected] | portados fundos
2 | [email protected] | parafernalha
3 | [email protected] | Ei nerd
4 | [email protected] | Canal Nostalgia
2nd entries
id | usuario | se_inscreveu_no_canal
1 | [email protected] | Ei nerd
2 | [email protected] | parafernalha
Summarizing what I need is to make a SELECT list only the channels that the user has not yet registered in the case of the example the [email protected] needs to be displayed only the Nostalgia Channel
$sql = "SELECT * FROM usuarios WHERE canal NOT EXIST IN(SELECT * FROM inscricoes WHERE o_usuario NOT IN se_inscreveu_no_canal) ORDER BY RAND();
I’m not a professional in the area, I just program as a hobby to make things simpler and this type of consultation is more advanced if you can help me in a way to solution since I thank you.
Follows a bit of structure for better understanding(well summarized)
php.
enter your email and channel nameINSERT INTO usuarios (usuario, canal) VALUES ('$_POST[email]',$_POST[canal]')"; READY REGISTER
listarcanais.php ( the user in this part is already logged in $user=Session[email]) SELECT * FROM usuarios ORDER BY canal LIMIT 1"; echo " CLICK HERE FOR YOURSELF ";
subscribe.php ( the user in this part is already logged in $user=Session[email]) $canal= $GET[canal]; INSERT INTO entries (user, channel) VALUES ('$user,$channel')"; //redirect to listarcanais.php PRONTO JA APPEARS IN THE COMIC BOOK THAT THE USER HAS ALREADY ENTERED IN THAT CHANNEL
listarcanais.php <<< as in my head think the system should read
SELECT CHANNEL FROM (table users) WHERE the (user=$user) DID NOT register ( in the table entries)
roughly: 1° a select that takes the (email/$user) and compares the USERS and SUBSCRIPTIONS tables in order to delete the other email that is not the $user one
done this 2° a select that lists all channels of the USUARIOS table and compares with all channels of the INSCRIPTIONS table. Those who are not equal will be listed
Your database structure can (I believe it should) be improved, I suggest a user table and another channel, in a relation N:N where the generated third table contains the user id and the id of the channels it is inscribed
– Costamilam