devotional_banner

Receive our daily devotionals to your email![Form id=”13″] [insert_php]

# Returns group_id of last record
function getLastGroupID($mysqli) {
$group_id = “”;
$form_id = ’10’; # id of “devotion” form
$query = “SELECT `group_id` FROM `wp_formmaker_submits` WHERE `form_id` = ‘$form_id’ ORDER BY `id` DESC LIMIT 1”;
$stmt = $mysqli->prepare($query);
$stmt->execute();
$stmt->bind_result($group_id);
$stmt->fetch();
return $group_id;
}

# Returns array with ‘title’, ‘date’, and ‘content’
function getDailyDevotion($mysqli) {
$lastGroupID = getLastGroupID($mysqli);
$element_label = array(
“title” => 1,
“date” => 2,
“content” => 13,
);
$result = array();
$query = “SELECT element_value FROM `wp_formmaker_submits` WHERE `group_id` = ? AND `element_label` = ?”;
foreach ($element_label as $k => $v) {
$stmt = $mysqli->prepare($query);
$stmt->bind_param(“ii”,$lastGroupID,$element_label[$k]);
$stmt->execute();
$stmt->bind_result($result[$k]);
$stmt->fetch();
$stmt->close();
}
return $result;
}

include “/home/content/w/a/y/waydestover/html/wp-config.php”;
$username = DB_USER;
$password = DB_PASSWORD;
$database = DB_NAME;
$hostname = “klm1325010342679.db.6602949.hostedresource.com”;
$mysqli = new mysqli($hostname, $username, $password,$database) or die( “Unable to connect to database”);
$result = getDailyDevotion($mysqli);
[/insert_php]

Title = [insert_php] echo $result[“title”]; [/insert_php] Date = [insert_php] echo $result[“date”]; [/insert_php] Content = [insert_php] echo $result[“content”]; [/insert_php]

Flag