Skip to content

Instantly share code, notes, and snippets.

@nitrix
Created April 12, 2013 15:28
Show Gist options
  • Save nitrix/5372879 to your computer and use it in GitHub Desktop.
Save nitrix/5372879 to your computer and use it in GitHub Desktop.
<?php
function prettyPrintSQLResult($result) {
$i=0;
echo '<table border="1">';
while ($data = $result->fetch_assoc()) {
if (!$i) {
//first entry
$columns = array_keys($data);
echo '<tr>';
foreach($columns as $c) {
echo '<th nowrap><strong>'.$c.'</strong></th>';
}
echo '</tr>';
}
echo '<tr>';
foreach($data as $value) {
echo '<td nowrap>'.$value.'</td>';
}
echo '</tr>';
$i++;
}
echo '</table>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment