Jump to content

Storing an array of id's in the database?


Solarpitch

Recommended Posts

Hey Guys,

In my application I have a "quicklist" which stores a few id's of products on the site. Each product the user selects will be added to this quicklist variable.

ie $quicklist[] = {4,5,42,6,17,64} --> each id is a reference to a product.

I want to be able to give the user the option of saving the quicklist to the database for later viewing. So I want to sore all the id's the user has selected . . {4,5,42,6,17,64}. Then when the user wishes to view his/ her quicklist, I can pull them from the DB and display in a table.

How could I achieve this?

Cheers,
Gerard.
Link to comment
https://forums.phpfreaks.com/topic/33650-storing-an-array-of-ids-in-the-database/
Share on other sites

Well, using an IN() clause, you could easily pull them back, especially if you store it with commas already.  Not that I condone storing lists of values in database fields, but as long as you never want them to be able to edit a quicklist, I might make an exception.

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.