Skip to content
Snippets Groups Projects
Commit 3fd8c43f authored by Angela Pham's avatar Angela Pham
Browse files

Week 4 lab added.Implementing SPOE navigation

parent ededafbe
Branches
No related merge requests found
<?php <?php
/* connect to the database */ require('includes/db_connect.php');
$link = mysqli_connect(
'localhost',
'ma302ap',
'anspj597',
'ma302ap_recordstore'
);
/* check connection succeeded */
if (mysqli_connect_errno()) {
exit(mysqli_connect_error());
}
$sql1 = "SELECT title, genre FROM record WHERE year = 2014";
$result1 = mysqli_query($link, $sql1); include('templates/header.html');
include('templates/navigation.html');
if ($result1 === false) { // get the value of the page parameter from the URL
echo( "No records found." ); // if no parameter detected...
echo mysqli_error($link); if (!isset($_GET['page'])) {
$page_id = 'home'; // display home page
} else { } else {
$page_id = $_GET['page']; // else requested page
}
echo( "<h1>Some records were found!</h1><br>" ); switch ($page_id) {
/* fetch associative array */ case 'home' :
while ($row = mysqli_fetch_assoc($result1)) { include 'views/home.php';
echo($row['title']." ".$row['genre']); break;
echo "<br>"; case 'record' :
} include 'views/record.php';
break;
/* Extension 1 - Output number of rows*/ case 'artist' :
$sql2 = "SELECT * FROM record"; include 'views/artist.php';
break;
$result2 = mysqli_query($link, $sql2); default :
$num_rows = mysqli_num_rows($result2); include 'views/404.php';
echo ($num_rows. " rows");
/* free result set */
mysqli_free_result($result1);
mysqli_free_result($result2);
} }
mysqli_close($link);
include('templates/footer.html');
mysqli_close($link);
?> ?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment