I have a form with checkboxes on it. if the user checks two or more checkboxes i use to compress all values in string format (example: dog|cat|chicken) then thats the time i will store it to my mysql database. it saves my database size coz instead of putting doc, cat, chicken in each row of my table i use to compress it.
is it a good practice? or what other technique to you use? thanks!
checkbox values inserting to mysql
Moderator: General Moderators
make your checkboxes an array then serialize() the array for insertion to the db.
theoretically you 'could' using the like operator, but that's not ideal.
I don't think you're any better off if you want to save them in the same column using a different method, but a cleaner solution would be to use implode() if you're planning on searching on those values...it's cleaner, but still not your 'best' solution.
you have two threads going that are basically asking the same questions.... I'm locking this one and you can continue any further discussions in the other.
I don't think you're any better off if you want to save them in the same column using a different method, but a cleaner solution would be to use implode() if you're planning on searching on those values...it's cleaner, but still not your 'best' solution.
you have two threads going that are basically asking the same questions.... I'm locking this one and you can continue any further discussions in the other.