Forum
retrieve the value of a select field in the perch2_form_resonses table
Hi
is it possible using SQL to retrive the value of a select box in a form
I know you can get the JSON strin but is there a way of just getting the entered value
so in my case i have a select box for an Australian state
<div class="state">
<perch:label for="state">State:</perch:label>
<perch:input type="select" options="VIC, NSW, QLD, SA, WA, NT, TAS " id="state" label="State" required="true" placeholder="Select"/>
</div>
which ends up in the database in the perch2_form_responses table and the responseJSON column as
{"fields":{"state":{"attributes":{"type":"select","options":"VIC, NSW, QLD, SA, WA, NT, TAS ","id":"state","label":"State","required":"true","placeholder":"Select"},"value":"NT"}},"files":[],"page":{"id":"1","title":"Home page","path":"\/","navtext":"Home page"}}
can i access the value:NT part as i am trying to do a report for a customer.
Regards,
Brett
Yes, use
json_decode()
to turn the string into an array.Hi Drew
Thanks for the above,
I can get the data from the file by
and then
which gives the whole string
i then try and get the value by
which gives me
i then tried
but get "trying to get property of non object"
how do i get the value of QLD out of the array
Regards,
Brett
hi Drew
i can get it with
is this the best way
regards,
Brett
This isn't really anything to do with Perch at this point - if it's working then it sounds like you have a solution.
Thanks
As you build more complex sites you just need to learn a bit more about how perch stores its data.
You can close this now.
Regards,
Brett