<?php
function showQuery($result = 0) {
if (!$result) $result = $this->result;
if (!$result) {
$this->_handleError("No result set to show!");
return;
}
// Convert column names to table headings
$html = "<table border>\n";
$html .= "<tr>\n";
$count = mysql_num_fields($result);
for ($i = 0; $i < $count; $i++) {
$html .= "<th>".mysql_field_name($result, $i)."</th>\n";
}
$html .= "</tr>\n";
// Convert data to table cells
@mysql_data_seek($result, 0);
$count = 0;
while ($row = mysql_fetch_row($result)) {
$html .= "<tr>\n";
foreach ($row as $item) {
$html .= "<td> $item</td>\n";
}
$html .= "</tr>\n";
$count++;
}
echo $html;
}
?>