Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Database field as an array?

Posted 20 Jul 2001 11:38:40
1
has voted
20 Jul 2001 11:38:40 Bec C posted:
I am building a page where I am allowing users to add other users to a friends list.

What is the best way to go about this?

Is there a way to append a single database field like a list

friend1, friend2, friend3 etc

when a user is added and then be able to get back at the values? It needs to act like an array where one field can contain many values!

Any other suggestions are greatly welcomed.

Thanks




Edited by - rawveg on 07/23/2001 15:38:54

Replies

Replied 20 Jul 2001 12:16:06
20 Jul 2001 12:16:06 Tim Green replied:
There's no reason at all why you can't do this. I quite often do it myself as it is a very flexible method. However, one caveat is that you will probably need to define the database field in question as a BLOB (or Binary Large Object) otherwise if the friends list of only one person is huge you'll soon find that it won't work !

There are various ways to turn an array into a comma separated list of values and back again. It really depends on the language that you are using to develop in.

For example in PHP you could do the following :-

To convert an array to a comma-separated list :-

$commaList=implode(",",$friendsArray);

and to convert it back :-

$friendsArray=explode(",",$commaList);

Hope this helps

Tim Green
Webmaster
www.rawveg.org (Coming Soon)

Edited by - rawveg on 07/20/2001 12:17:30

Edited by - rawveg on 07/20/2001 12:18:45
Replied 20 Jul 2001 14:55:07
20 Jul 2001 14:55:07 Bec C replied:
Thanks for the reply.

I am coding the page in VB Script - do you know how I would convert a comma list?

Thanks

Replied 21 Jul 2001 14:40:04
21 Jul 2001 14:40:04 Tim Green replied:
Thread moved back to UltraDev forum

Tim Green
Webmaster
www.rawveg.org (Coming Soon)

Reply to this topic