This is an example of a table from a Gravity form which has been put into a database (Mysql)
What Im doing is catching certain values from a submitted form and then comparing those values against another forms previously submitted values. I have managed to grab the values from the submitted form using gform_after_submission hook, its jsut the grabbing the value from the other forms database after matching.
Table layout
--------------------------------------------------
/ Lead_id / Form_id /Field_number/ value /
/-----------------------------------------------
/ 3 / 4 / 2 / email@email.com
---------------------------------------------------
/ 4 / 4 / 4 / name mcname
--------------------------------------------------
/ 5 / 4 / 7 / Skype
--------------------------------------------------
/ 6 / 3 / 2 / email2@email2.com
-----------------------------------------------------
/ 7 / 3 / 4 / name2 mcname2
-----------------------------------------------------
/ 8 / 3 / 7 / TELEPHONE
----------------------------------------------------
So i have the value of "skype" And Im checking to see if the value skype is in the table and if so then I want to grab the data from the value where Field_number = 2 (the email address)
But Im having difficulty grabbing this value.
Here is where Ive ended up
$ContactMethods = "Skype";
$feildNum = 2;
$getEmailmentor = (float) $feildNum;
$SQL = "SELECT * FROM wp_rg_lead_detail WHERE field_number = '$getEmailmentor' AND $ContactMethods = value";
$result = mysql_query($SQL);
while($row = mysql_fetch_array($result)) {
// OUTPUT EMAIL
echo $row['value']."<b/>";
}
The idea is to grab the email and then send an email to a match by $ContactMethods
I'm not great at MYSQL queries and would appreciate the help, Ive tried googling different ways to do this but I seem to be going around in circles.