我一直在WordPress CMS上使用Gravity Forms构建表单。 所有字段都保存在MySQL中,但是现在我需要在Drupal CMS中检索这些数据。
已经创建了与正确数据库的连接,但我不知道如何正确地从MySQL中检索数据。
创建表单的每个人都有自己的ID,在这些ID中,我们有一些具有自己值的field_numbers。 例如: 已创建表单ID号1,并创建了具有不同值的不同field_numbers(即每个问题,可能是单选框,复选框或打开的问题)。
我需要使用相应的值检索此表单。 这些表被称为: lead_id(这是潜在客户的数量)。 field_number(这些是Gravity Forms创建的字段的编号)。 value(给某种field_number的答案)。
我希望这不难理解。不知道如何解释..... 我需要从所有ID(创建的表单)中检索field_number 9值。 感谢所有人看看这个..
我需要检索
答案 0 :(得分:0)
我找到了从Gravity Forms检索数据的答案。 以下是如何从不同平台(无WordPress)检索数据的完整示例。
$servername = 'localhost';
$username = 'your_username';
$password = 'your_password';
$conn = mysql_connect($servername, $username, $password);
mysql_select_db('your_databasename');
$sql = 'select lead_id as entryId
,(select value from bjj where field_number=1 and lead_id = entryId) as email
,(select value from bjj where round(field_number,2) = 57.3 and lead_id = entryId) as first_name
,(select value from bjj where round(field_number,2) = 57.6 and lead_id = entryId) as last_name
,(select value from bjj where round(field_number,2) = 58.1 and lead_id = entryId) as address1
,(select value from bjj where round(field_number,2) = 58.2 and lead_id = entryId) as address2
,(select value from bjj where round(field_number,2) = 58.3 and lead_id = entryId) as city
,(select value from bjj where round(field_number,2) = 58.4 and lead_id = entryId) as state
,(select value from bjj where round(field_number,2) = 58.5 and lead_id = entryId) as zip
,(select value from bjj where round(field_number,2) = 58.6 and lead_id = entryId) as country
,(select value from bjj where round(field_number,2) = 63.0 and lead_id = entryId) as phone
,(select value from bjj where round(field_number,2) = 66.0 and lead_id = entryId) as age
from bjj
group by entryId order by entryId desc';
$result = mysql_query ($sql, $conn);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
// output data of each row
echo "<div class='block-information-leads' style='width: 33%; float: left; border: 1px solid black; margin-top: 10px;'>Voor en achternaam: " . $row["first_name"] . " " . $row["last_name"] . "<br />Type keuken: " . $row["email"]. "<br />Land: " . $row["country"]. "</div>";
}
mysql_close($link);
?>
$servername = 'localhost';
$username = 'your_username';
$password = 'your_password';
$conn = mysql_connect($servername, $username, $password);
mysql_select_db('your_databasename');
$sql = 'select lead_id as entryId
,(select value from bjj where field_number=1 and lead_id = entryId) as email
,(select value from bjj where round(field_number,2) = 57.3 and lead_id = entryId) as first_name
,(select value from bjj where round(field_number,2) = 57.6 and lead_id = entryId) as last_name
,(select value from bjj where round(field_number,2) = 58.1 and lead_id = entryId) as address1
,(select value from bjj where round(field_number,2) = 58.2 and lead_id = entryId) as address2
,(select value from bjj where round(field_number,2) = 58.3 and lead_id = entryId) as city
,(select value from bjj where round(field_number,2) = 58.4 and lead_id = entryId) as state
,(select value from bjj where round(field_number,2) = 58.5 and lead_id = entryId) as zip
,(select value from bjj where round(field_number,2) = 58.6 and lead_id = entryId) as country
,(select value from bjj where round(field_number,2) = 63.0 and lead_id = entryId) as phone
,(select value from bjj where round(field_number,2) = 66.0 and lead_id = entryId) as age
from bjj
group by entryId order by entryId desc';
$result = mysql_query ($sql, $conn);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
// output data of each row
echo "<div class='block-information-leads' style='width: 33%; float: left; border: 1px solid black; margin-top: 10px;'>Voor en achternaam: " . $row["first_name"] . " " . $row["last_name"] . "<br />Type keuken: " . $row["email"]. "<br />Land: " . $row["country"]. "</div>";
}
mysql_close($link);
?>