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

Week 4 lab added.Implementing SPOE navigation

parent d611dda6
Branches
No related merge requests found
<?php
echo("Error 404: Page not found.");
?>
<?php
$content = "<h1>Angela's Record Store</h1>";
$sql1 = "SELECT first_name, last_name FROM artist";
$result1 = mysqli_query($link, $sql1);
if ($result1 === false) {
echo( "No records found." );
echo mysqli_error($link);
} else {
$content .= "<table border='1'> <tbody>";
$content .="<th colspan='2'>Artists</th>";
$content .= "<tr>";
$content .= "<th>First Name</th>";
$content .= "<th>Last Name</th>";
$content .= "</tr>";
/* fetch associative array */
while ($row = mysqli_fetch_assoc($result1)) {
$content .= "<tr>";
$content .= "<td>".$row['first_name']."</td>";
$content .= "<td>".$row['last_name']."</td>";
$content .= "</tr>";
}
$content .= "</tbody></table>";
/* free result set */
mysqli_free_result($result1);
}
echo $content;
?>
<?php
$content = "<h1>Welcome to Angela's Record Store</h1>";
echo $content;
?>
<?php
// create variable for content HTML
$content = "<h1>Angela's Record Store</h1>";
$sql1 = "SELECT title, genre, price FROM record";
$result1 = mysqli_query($link, $sql1);
if ($result1 === false) {
//echo( "No records found." );
echo mysqli_error($link);
} else {
$content .= "<table border='1'><tbody>";
$content .="<th colspan='3'>Records</th>";
$content .= "<tr>";
$content .= "<th>Title</th>";
$content .= "<th>Genre</th>";
$content .= "<th>Price</th>";
$content .= "</tr>";
/* fetch associative array */
while ($row = mysqli_fetch_assoc($result1))
{
$content .= "<tr>";
$content .= "<td>".$row['title']."</td>";
$content .= "<td>".$row['genre']."</td>";
$content .= "<td>".$row['price']."</td>";
$content .= "</tr>";
}
$content .= "</tbody></table>";
/* Extension 1 - Output number of rows
$sql2 = "SELECT * FROM record";
$result2 = mysqli_query($link, $sql2);
$num_rows = mysqli_num_rows($result2);
echo ($num_rows. " rows");
*/
/* free result set */
mysqli_free_result($result1);
// mysqli_free_result($result2);
}
echo $content;
?>
\ 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