Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey guys,
This one seems simple but I can't wrap my brain around it. Basically I have a table in my DB that cloects id's. When it first starts it is empty but when someone adds an id it needs to append to the list in there. I figure to seperate the list with commas so I can have a way of dividing it when I need to. So basically I need to take whats in there, add a comma and id to it then put it back. I may start the table off with a ,1 just so I have a starting point. I am thinking I need to use explode to turn it into an array, array_push to put the "," and "3(number)" in the array then put it back together and update the field. Think of it along the lines of each person having an id and adding a friend to your profile (as within a social network). Any help would be appreciated.

I would suggest you scrap that idea entirely. The strength of using a "relational" database is in using different tables with related records.
In this instance you have usr table. Each record in that table has an ID, correct? So you should then create a second table such as friends. That table would only need two columns: user_id & friend_id. You can then have a many-to-one relationship. A user can have many records in the firend table that point back to the record in the user table.
You can then get very complex datasets from the database with a single query. For example you could get a list of all fiends for a single user with one query. With the method above you would first have to query for the user, then extract the data to then query for the friends.
Michael J

He Michael, I actually figured it out but your are right. In fact i have a request table that has a too and from column in it that gets deleted once someone says approve or deny, I can just use tha with different code, good idea.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |