Skip to content

Instantly share code, notes, and snippets.

@emyb
Created June 15, 2021 19:35
Show Gist options
  • Save emyb/14ba000f5ae95775d2c7f9ff98732f04 to your computer and use it in GitHub Desktop.
Save emyb/14ba000f5ae95775d2c7f9ff98732f04 to your computer and use it in GitHub Desktop.
<?php
// A simple file to do some php stuff then do some html stuff.
// Make connection to the database, query the database, get the results.
$records = [
['id' => 1, 'firstname' => 'Harry', 'lastname' => 'Potter'],
['id' => 2, 'firstname' => 'Hermione', 'lastname' => 'Granger']
['id' => 3, 'firstname' => 'Ronald', 'lastname' => 'Weasly'],
['id' => 3, 'firstname' => 'Tom', 'lastname' => 'Riddle']
];
?>
<div class="outer-div">
<?php
// Loop over the records.
for ($i = 0; $i < count($records); $i++) {
?>
<div class="inner-div">Person id: <?php echo $records[$i]['id']; ?></div>
<div class="inner-div">Person name: <?php echo "{$records[$i]['firstname']} {$records[$i]['lastname']}"; ?></div>
<?php
// The end of the loop.
}
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment