Created
June 15, 2021 19:35
-
-
Save emyb/14ba000f5ae95775d2c7f9ff98732f04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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