How to save multiple input entries in one column in mysql using php?
Serialization method – serialize() is to store multiple fields in single column. PHP is able to automatically serialize most of its variables to strings – letting you save them into storage like $_SESSION. However, there are some tweaks you have to know to avoid exploding .php scripts and performance problems.
serialize() converts an array, given as its only parameter, into a normal string that you can save in a file, pass in a URL, etc. Unserialize() is the opposite of serialize() – it takes a serialized string and converts it back to an array.
On Post request you have received $_POST data for name, mobile, address, email.
<?php $data = $_POST; $data_serialize = serialize($data); ?>
resulting array will be
use this serialized string to insert into database.
Unserialize value from DB:
$data_unserialize = unserialize($records_serialize);
More Related Articles
- Previous Post
- Next Post