in Education by
On my website I am trying to program a feature, similar to facebook and twitters timeline, where a user can 'follow' another user, and receive their 'broadcast'. The database tables are: **members** -------- id fullname following **broadcasts** ----------- id mem_id broadcast (the content) broadcast_date "following" in the members table is a varchar text that stores user ID's. So if I'm following users 4 5 and 6 (4,5,6,) would appear in the following column. My problem is, what I'm querying from the database, it's only retrieving the 'broadcasts' from the first user that I am following and no other user else. $sql_broadcasts = mysql_query(" SELECT * FROM members JOIN broadcast ON(broadcast.mem_id = members.following) WHERE members.id=$id ORDER BY broadcast_date DESC LIMIT 10; "); where $id is $_SESSION['id']. I've been staring at this code for a long time, can anyone spot what I'm doing wrong? thanks in advance JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Joins do not work that way. Assuming that broadcast.mem_id is a numeric type the database will silently cast members.follower_array; this will make 4 from 4,5,6, so one record matches. You will need a m:n relation for this to work, one table with members (which you already have); and another table with followers, for each follower you insert a record which contains the member id of the member who is being and the member id of the member who is following. That way a member can have 0-n followers. Table member id Table follower member_id member_id_follower Then you can do something like SELECT ... FROM member AS mb JOIN follower AS fl ON fl.member_id = mb.id WHERE mb.id = 123

Related questions

0 votes
    On my website I am trying to program a feature, similar to facebook and twitters timeline, where a user ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I am getting empty row on following sql SELECT * FROM flyers WHERE fId='6' AND 'userId'='400' ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    Why does this mysql query fail? UPDATE accounts SET motivation = IF(motivation+100...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I would like to implement a very small and simple group chat into my website without using any 3rd party ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    We are in the process to update an existing WordPress website and imported posts from one site to another. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    The tables are: 1) Producers: id, name 2) Products: id, name, price, category_id, producer_id 3) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    I would like to implement a very small and simple group chat into my website without using any 3rd party ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    We are in the process to update an existing WordPress website and imported posts from one site to another. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    We are in the process to update an existing WordPress website and imported posts from one site to another. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    We are in the process to update an existing WordPress website and imported posts from one site to another. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    My goal is to merge tables from different schema into one single schema so I would like to execute this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I need to take the users input from the select box for Allergen1 once an option is selected and the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I am facing issue of very slow result. I am sharing table structure as and results also. if you ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    Is there an easy way to run a MySQL query from the Linux command line and output the results in CSV format? Here's what I'm doing now: mysql -u uid -ppwd -D dbname...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I'm trying to produce a page that would function a bit like a digital sticker album. My SQL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
...