Last active
May 24, 2016 23:10
-
-
Save samueljon/93f5e7175615584f2e30420c2d81cc2d to your computer and use it in GitHub Desktop.
example for a friend
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
<html> | |
<body> | |
<?php | |
$rows = array( | |
'0' => array( 'name' => 'Herbert', 'phone' => '4312244'), | |
'1' => array( 'name' => 'Herbert2', 'phone' => '4312266'), | |
); | |
?> | |
<!-- Table --> | |
<php if(!empty($rows) : ?> | |
<div id="myid" class="myclass"> | |
<table> | |
<tr> | |
<th>Dálkur 1</th> | |
<th>Dálkur 2</th> | |
</tr> | |
<?php | |
foreach ($rows as $row) { | |
print '<tr>'; | |
print '<td>' . $row['name'] . '</td><td>' . $row['phone'] . '</td>'; | |
print '</tr>'; | |
} | |
?> | |
</table> | |
</div> | |
<?php endif; ?> | |
<!-- Annað dæmi --> | |
<?php | |
$output = '<table>'; | |
$output .= '<tr>'; | |
$output .= '<th>Dálkur 1</th>'; | |
$output .= '<th>Dálkur 2</th>'; | |
$output .= '</tr>'; | |
foreach ($rows as $row) { | |
$output .= '<tr>'; | |
$output .= '<td>' . $row['name'] . '</td><td>' . $row['phone'] . '</td>'; | |
$output .= '</tr>'; | |
} | |
$output .= '</table>'; | |
json_encode($output); | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment