Jump to content

Inserting multiple data into 1 field


Samvh

Recommended Posts

Hello, I'm trying to insert multiple data into 1 field.

 

My table is called 'members' with a couple of fields in it, One of them is friends.

So I've made a little community system where you can add a friend.

 

The problem is that I'm trying to insert the id's from the friends into 1 field.

for example: 1,2,3,4,... So later on I can select all the ID's from that field and display them.

 

At the moment I simply use: (UPDATE members SET friends='$friend_id' WHERE id='$userid').

But everytime I click on "add friend" it replaces ID's (pretty normal).

 

I heard it's possible using arrays. (I dont know alot about arrays so keep it simple  :P)

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/241335-inserting-multiple-data-into-1-field/
Share on other sites

Thanks for the quick response.

My table is pretty basic

 

id - fullname - country - email - password - friends

 

1 - Ben Vletren - Belgium - [email protected] - 123 - 0

 

So as you can see under friends is 0. If you add a friend it should become the id of that friend (example 5), add another friend (with id 12) and it should become 5, 12 (and so one).

 

If there's a better way to do this please let me know.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.