04 Sessions Mysql20 3.01 Mysqli_integer_01
A total of 8 records were found.
A total of 8 records were found.
$_SERVER["SCRIPT_NAME"]
/php/assignments/04-sessions-mysql/20-3.01-mysqli_integer_01.php
print_r($_GET)
Array
(
)
print_r($_POST)
Array
(
)
print_r($_SESSION)
Array
(
)
print_r($_FILES)
Array
(
)
<?php
// Database Connection
require_once('../../includes/connection.php');
// Utility Functions
require_once '../../includes/utility_funcs.php';
// Connect to Database Using MySQL
$conn = dbConnect('read');
// Prepare the SQL query
$getImages = 'SELECT image_id, filename
FROM php_a04_images
';
// Submit the Query and Capture the Result
$images = $conn->query($getImages);
// Check For Database Errors
if (!$images) {
$error = $conn->error;
} else {
$numRows = $images->num_rows;
}
$tools = true;
include("../../includes/header.php");
?>
<main>
<h2><?php echo $folder_name; ?><span><?php echo $file_name; ?></span></h2>
<?php
if (isset($error)) {
echo "<p class=\"error\">$error</p>";
} else {
echo "<p class=\"info\">A total of $numRows records were found.</p>";
}
?>
<figure class="code">
<pre class="language-sql"><code><?= $getImages ?></code></pre>
</figure>
<form method="get" id="form1">
<fieldset>
<legend><?php echo $file_name; ?></legend>
<ol>
<li>
<select name="image_id" id="image_id">
<?php
while ($row = $images->fetch_assoc()) {
$id = $row['image_id'];
$filename = safe($row['filename']);
// Is current $row['image_id'] == $_GET['image_id'] then selected="selected"
if (isset($_GET['image_id']) && $_GET['image_id'] == $row['image_id']) {
$selected = ' selected';
} else {
$selected = null;
}
?><option value="<?= $id ?>" <?= $selected ?? $selected ?>><?= $filename ?></option>
<?php } // END while
?>
</select>
</li>
<li>
<input type="submit" name="go" id="go" value="Display">
</li>
</ol>
</fieldset>
</form>
</main>
<?php
# The side-bar section of the layout use custom path to load from a different folder.
include("../../includes/sidebar.php");
# The footer section of the layout.
include("../../includes/footer.php");
?>