-
Notifications
You must be signed in to change notification settings - Fork 0
/
search_scripture.php
56 lines (48 loc) · 1.25 KB
/
search_scripture.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<article>
</article>
<?php
function test() {
$server = getenv('OPENSHIFT_MYSQL_DB_HOST');
$database = 'scriptures';
$username = getenv('OPENSHIFT_MYSQL_DB_USERNAME');
$password = getenv('OPENSHIFT_MYSQL_DB_PASSWORD');
$dsn = 'mysql:host='.$server.';dbname='.$database;
try{
$g1db = new PDO($dsn, $username, $password);
return $g1db;
}
catch (PDOException $ex){
echo 'Error!:' . $ex->getMessage();
exit();
}
}
$test = test();
function viewBooks() {
global $test;
$query = 'SELECT * FROM books
ORDER BY book_id';
$statement = $test->prepare($query);
$statement->execute();
$books = $statement->fetchAll();
$statement->closeCursor();
return $books;
}
$books = viewBooks();
?>
<article>
<center>
<h1>Search Scripture</h1>
<form action="ScripturesDB.php" method="post">
<label>Select Book</label>
<select class="form-control" name="book" >
<option value="all">All</option>
<?php foreach ($books as $book): ?>
<option value="<?php echo $book["book_id"]; ?>"><?php echo $book["name"]; ?></option>
<?php endforeach; ?>
</select>
<input type="submit" value="Send" class="btn btn-default">
</form>
<a href="scriptureInsert.php"><h3>Add a scripture</h3></a>
<a href="index.html"><h3>Home</h3></a>
</center>
</article>