I have a jQuery field which enables my visitors to search for elements. These elements are stored in JSON format and the unique ID’s taken from the database are stored as such below (in the ‘value’ field):
<input type="hidden" class="as-values"
name="as_values_category" id="as-values-category" value="9,11,12,">
Obviously, the 3 values shown are if the visitor chooses 3 elements. The user can choose 1-3 elements, resulting in up to 3 results.
The user then goes on and submits the entire page using php. I now need a way to store these 3 variables in the database. How do I ‘Get’ this data. The ‘id’ of the form is unique and will always be named ‘as-values-category’.
I would then need to go and parse the value to separate the 3 values which I am hoping shouldn’t be a problem.
Many thanks in advance.
After you submit the form, on the form handler page you can do:
After that,
$idsshould be an array containing the elements 9, 11 and 12 (according to your example above).Update
You can iterate through all of the ids with a
foreachloop, like so:This should output: