Jump to content

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 - ben@hotmail.com - 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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.