Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Array in a Table

Array in a Table

Array in a Table

Hi, I'm working on an application, and I need to be able to be able to store and (easily) edit array data to/within a table. For instance, a field name may be "units" and I would need to store multiple values from another table to that field as some sort of array, for instance a user may enter numbers such as "401" but later add another such as "510". I need to be able to add an indefinite number of values to this field. Any help is greatly appreciated!

RE: Array in a Table


Rather than a field named UNITS, make a field named, for instance, CATEGORY, and a field named CAT_VALUE.

Then when you have UNITS with a value of “401”, enter “UNITS” in CATEGORY and “401” in CAT_VALUE. Then “WIDGET” and “702” etc.

When you want all the UNITS values, run a query...


FROM YourTableName


glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Array in a Table

You can store serialized arrays in a mysql text field type. Serializing takes an array and turns it into a string you can store in a DB table.

If using PHP for instance, you can call the serialize and unserialize functions to turn an array into a string you can store in a single table value.

When you unserialize it, you can have your code use it as regular array, and add and remove entries, and then serialize it, and save it back to the table.

Phil AKA Vacunita
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close