0

I am using PHP. I need to store the multiple values at a single column. The values are come from depending on the checkbox selected. I didnt use the array for checkbox name. What can I do?

2 Answers 2

1

You just need to find a standard way to store the information as a longer string.

So, for example, if you know '__' isn't going to show up in your data then you can store checkboxvalue__otherdata, but has risk.

As alex mentioned, if you use json, http://json.org, then you will put information into this object and then save it as a string, but to be safe you should base64 encode it.

Or you could store it in an xml file.

If you were just saving 2 bytes, for example, then you could push them into an int, and then decode it later.

Basically, just determine some way that works for you to store the type of data you want to store.

If you have a signed into that is always less than 2G and greater than 0 then you could put the checkbox (0 or 1) into the first bit of an unsigned int.

You didn't specify what the data you want to store is, so it is hard to give more detail.

Sign up to request clarification or add additional context in comments.

Comments

0

If you had them in an array or object, you could serialise() before inserting into the db.

Alternatively, if you want something more readable, you could do json_encode() (but takes up more room).

2 Comments

I didnt use the array for getting values.Then how can I store?I need little more explanation....Thanks in advance..
you can put them in array and then store. the syntax is $arr = array("foo" => "bar", 12 => true); What bothers is why do you have to do this. If you have flat array create a second column. If you have more levels create a table and join it when selecting values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.