Hi I have an array of Services ordered by user like below $_POST values printed
Array
(
[compaignID] => 4
[totalChecked] => 3
[hear_about_us] => Google
[videolink] =>
[LinkedIn] => Array
(
[0] => 1
[1] => 1
[2] => http://developer.comoj.com
)
[Facebook] => Array
(
[0] =>
[1] =>
)
[Twitter] => Array
(
[0] =>
[1] =>
)
[YouTube] => Array
(
[0] => 2
[1] => 4
[2] => http://developer.comoj.com
)
[Coupon_Area] => Array
(
[0] =>
[1] =>
)
[Website] => Array
(
[0] =>
[1] =>
)
[Google_Map] => Array
(
[0] =>
[1] =>
)
[Email] => Array
(
[0] => 3
[1] => 8
[2] => http://developer.comoj.com
)
[Share_To_Social_Media] => Array
(
[0] =>
[1] =>
)
[btnSubmit] => Submit
)
I’m confused how to store these. I made these arrays in php form to make their groups like below
for Orders Input field
<input name="<?php echo $service; ?>[]" type="text" id="order<?php echo $service; ?>" size="4">
for Services Check boxes to check which services to take
<input name="<?php echo $service; ?>[]" type="checkbox" id="show<?php echo $service; ?>" value="<?php echo $serviceID; ?>" onclick="countChecked();">
And for Services WebURL the input field below like
<input name="<?php echo $service; ?>[]" type="text" id="<?php echo $service; ?>" size="40">
I’m confused how to get only arrays which have values and store only these services their order number like for showing ascending or descending and their webrurls against each checked checkbox.
I’m confused how to loop through and store in mysql.
Please help me.
Many Thanks
You can take help of
json_encode()andjson_decode()functions of PHP solve these things.To store and array into
mysql, you should usejson_encode($yourArray);and you should store the returned string intomysql.Similarly for retrieving, you should use
json_decode($yourMySqlStoredString)and this will return the array back to you, which you can use for your further manupulations!json_encode php function
json_decode php function