Am using wordpress and phpmyadmin for handling my database. Below is the code I use to view entries on my form using python. In the form I ask users to check/uncheck specific questions.
import MySQLdb as mdb
con = mdb.connect('localhost', 'root', 'password', 'WordpressDB', unix_socket="/opt/lampp/var/mysql/mysql.sock");
with con:
cur = con.cursor()
cur.execute("SELECT data FROM `wp_form_builder_entries` WHERE entries_id = 5")
rows = cur.fetchall()
print rows
Output generated by this code is as follows :
Works just as desired but I don't want all the data. I just need to know whether its checked or unchecked. If the user has checked value is "s:9:'checked'" else its "s:9:'unchecked'"
What query should I use to retrieve "s:9:'checked'" ?
Please advice
Thank you
You can not simply do this using a SQL Query. You have to deserialise the PHP data using phpserialize and get the data from it. See also other answer.