foreach ($topic_names as $topic_name) { $topic = getTopicByName($topic_name); while ($topic === NULL) { $result = insertTopic($name); if ($result != 1) { $topic = getTopicByName($name); } } $topics[] = $topic; } $scripture["book_id"] = $book["book_id"]; $scripture["chapter"] = $chapter; $scripture["verse"] = $verse; $scripture["content"] = $content; require_once 'model/scriptures.php'; insertScripture($scripture, $topics); header('location: /?action=searchscriptures'); break; case "scripture_result": require_once 'private/dbtest.php'; require_once 'model/scriptures.php'; $book = filter_input(INPUT_POST, 'book'); if (!isset($book) || $book == "all") { $scriptures = getScriptures(); } else { $scriptures = getScripturesByBook($book); } $max = count($scriptures); require_once 'model/topics.php'; for ($i = 0; $i < $max; $i++) { $topics = getTopicsByScripture($scripture["scripture_id"]);
foreach ($topics as $topic) { $query = ' INSERT INTO link (scripture_id, topic_id) VALUES (:scripture_id, :topic_id)'; $statement = $test->prepare($query); $statement->bindValue(":scripture_id", $scripture_id); $statement->bindValue(":topic_id", $topic["topic_id"]); $statement->execute(); $statement->closeCursor(); } // End and send the Transaction to the database --> $test->commit(); echo "scripture has been posted"; } insertScripture(); ?> <article> <HEAD> <HEAD> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <style> body { background-color: #FFF8DC; } h1 {