Skip to content

Instantly share code, notes, and snippets.

@samueljon
Last active May 24, 2016 23:10
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 samueljon/93f5e7175615584f2e30420c2d81cc2d to your computer and use it in GitHub Desktop.
Save samueljon/93f5e7175615584f2e30420c2d81cc2d to your computer and use it in GitHub Desktop.
example for a friend
<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