Skip to content

Instantly share code, notes, and snippets.

@asathoor
Last active October 2, 2017 11:21
Show Gist options
  • Save asathoor/4c3253ae54b4c0e438b2e8d2cd8d6d96 to your computer and use it in GitHub Desktop.
Save asathoor/4c3253ae54b4c0e438b2e8d2cd8d6d96 to your computer and use it in GitHub Desktop.

Kode fra undervisning d. 2.10. 2017 CNT1

<?php
/*
file: actors.php
purpose: a list of actors from the sakila database
*/
//require_once 'header.php'; // html header
require 'db.php'; // the mysqli object
$sql = "SELECT * FROM `holdliste`";
$result = $mysqli->query($sql); // query
?>
<h2>Actors</h2>
<?php
// looping out the result
while($row = $result->fetch_assoc()){
echo $row['hold_navn'] . " " . $row['navn'] . "<br>";
}
mysqli_close($mysqli);
//require_once 'footer.php'; // html footer
?>
<?php
/*
file: actors.php
purpose: a list of actors from the sakila database
*/
require_once 'header.php'; // html header
require 'db.php'; // the mysqli object
$sql = "SELECT * FROM `holdliste`";
$result = $mysqli->query($sql); // query
?>
<h2>Holdliste</h2>
<?php
// looping out the result
echo "<table>\n";
while($row = $result->fetch_assoc()){
echo "<tr><td class='roed'>" . $row['hold_navn'] . "</td><td>" . $row['navn'] . "</td></tr>\n";
}
echo "</table>\n";
mysqli_close($mysqli);
require_once 'footer.php'; // html footer
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment