Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamZWinter/3312630d4d400092a3b3e26c650f8091 to your computer and use it in GitHub Desktop.
Save AdamZWinter/3312630d4d400092a3b3e26c650f8091 to your computer and use it in GitHub Desktop.
Common steps for displaying database table.
<?php
require('/var/www/html/.../header.php');
$active = 'yes';
$query = "SELECT * FROM calendars WHERE active = ?";
$stmt = $db->prepare($query);
$stmt->bind_param('s', $active);
$stmt->execute();
$result = $stmt->get_result();
echo '<table>';
while ($row = $result->fetch_row()) {
echo '<tr>';
foreach($row as $columnValue){
echo '<td><p>'.$columnValue.'</p></td>';
}
echo '</tr>';
}
echo '</table>';
$result->close();
$stmt->close();
require('/var/www/html/.../footer.php');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment