Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8044437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:13:40+00:00 2026-06-05T05:13:40+00:00

I made a simple following-follower system with php(pdo) and mysql. My problem is, Let’s

  • 0

I made a simple following-follower system with php(pdo) and mysql. My problem is,

Let’s say there is a user name Mike with ID number 99. And Mike has two followers, Greg(id = 77) and Jenny(id = 88)

Greg’s following list looks like this (1,2,3,4,99), and Jenny’s following list looks like this (5,6,99,7)

What I am trying to do is, when Mike(99) deletes his account, I want to remove id number 99 from Greg(77) and Jenny(88)’s following lists.

Table called ‘mytable’ has 3 fields. id(INT), following_list(text), follower_list(text).

I’ve been struggling with this problem for a few days. Can anyone please give me some advice? Thank you so much in advance!!!

Below is my update function

public function update_following_list(){
   // $this->myid is Mike's id number(99) who is about to delete his account
   // Selecting the list of people following Mike
   $query = "SELECT 'follower_list' FROM 'mytable' WHERE 'id' = $this->myid";
   $result = $this->dbc->query($query);
      foreach($result as $row){
      $this->follower_list = $row['follower_list'];
      // When I echo $this->follower_list, I get 77,88

      // Now querying Greg(77) and Jenny(88)'s following_lists, which have Mike's id number(99) in them.
      $query = "SELECT 'following_list' FROM 'mytable' WHERE 'id' IN ($this->follower_list)";
      $result = $this->dbc->query($query);
         foreach($result as $row){
         $this->following_list = $row['following_list'];
         // When I echo $this->following_list, I get both Greg(1,2,3,4,99) and Jenny(5,6,99,7)'s following lists

         // Here, I am turning following list into array by using explode
         $this->following_array = explode(",", $this->following_list);
            foreach($this->following_array as $key => $value){
            if($value == $this->myid){

                // Removing Mike(99)'s id number from Greg and Jenny's following lists
                unset($this->following_array[$key]);

                // Add back commas, which will then become string
                $this->new_following_list = implode(",", $this->_following_array);
                // When I echo $this->new_following_list, I get both Greg(1,2,3,4) and Jenny(5,6,7)'s new list without Mike(99)'s id number 

// My problem starts here. I was able to remove Mike's id number from Greg and Jenny's lists. But I am having a trouble updating Greg and Jenny's following lists with new following lists.  

            // The update query below does not work...
            $query = "UPDATE 'mytable' SET 'following_list' = $this->new_following_list WHERE 'id' IN ($this->follower_list)";
            $result = $this->dbc->query($query);
        } // End of if($value == $this->myid)
        } // End of foreach($this->following_array as $key => $value)
    }
    } 
} // End of function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:13:42+00:00Added an answer on June 5, 2026 at 5:13 am

    This will not scale properly. It’s better to normalize your data model like this:

    following

    user_id | following_user_id
    ---------------------------
         77 |                 1
         77 |                 2
         77 |                 3
         77 |                 4
         77 |                99
         88 |                 5
         88 |                 6
         88 |                 7
         88 |                99
    

    And add two indexes:

    • UNIQUE(user_id, following_user_id)
    • INDEX(following_user_id)

    To get followers of 99:

    SELECT * FROM following WHERE following_user_id=99;
    

    To see who 77 follows:

    SELECT * FROM following WHERE user_id=77;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
I have a simple nav made up of the following HTML; <div class=inner> <div
Very simple question, I made the following program : #include <stdlib.h> int main(int argc,
On Windows, testing different OSes is made simple using VMs. Is there a simple
I have a made a simple program that reproduces the problem: #include <boost/archive/text_oarchive.hpp> #include
I made a simple ajax live search in PHP and javascript. I used standard
I've made a simple app, where I have a list of songs. The user
Considering the following simple entity association: (EntityA) *-1 (EntityB) made in database with a
Following this answer , I made a simple example to be sure I properly
The following javascript works with a simple test site i made, but does not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.