I am trying to create a SELECT statement that requires multiple WHERE conditions. Is that possible. Here is the scenario. I have a table with the following structure.
FormID (Type Int)
SubmissionID (Type Int)
FieldName (Type text)
FieldValue (Type text)
The data would be something like this.
FormID - SubmissionID - FieldName - FieldValue
24 ------ 5 ---------- username ------ johnk
24 ------ 5 ---------- firstname ------ John
24 ------ 5 ---------- lastname ------ King
24 ------ 5 ---------- address ------ 100 some street
24 ------ 5 ---------- email ------
johnemail@gma.com
24 ------ 9 ---------- username ------ cathym
24 ------ 9 ---------- firstname ------ Catherine
24 ------ 9 ---------- lastname ------ Mirusia
24 ------ 9 ---------- address ------ 100 some other street
24 ------ 9 ---------- email ------
cathyemail@gma.com
As you can see the "FieldName", "FieldValue" etc are the actual names of the Fields of the table.
Then fieldnames are stored in the table along with it's fieldvalue for each forms. Therefore "username", "firstname", "lastname", "address" and "email" are the actual fields in form 24 and when the User submit their information, it gets stored in the table as shown above.
I want to show the details of the User in another area using their emailID as the key field.
Essentially this is what has to happen ($user->email gives the email of the current User):
1. SELECT username WHERE (FieldName = "email") AND (FieldValue = " $user->email")
But in reality to get the values "johnk" and "cathym" in my example, what it seems that I have to do is the following but I am not sure how to code that:
2. SELECT FieldValue WHERE (FieldName = "username") (WHERE (FieldName = "email") AND (FieldValue = " $user->email"))
Can someone please help me with this scripting?
This is for a Joomla site using RSForm!Pro. RSForm!Pro stores the form input in the above manner!!!