I have written this:
<?
function do_it($result) {
$fields = mysql_num_fields($result);
$records = mysql_num_rows($result);
echo "Records: $records / Fields: $fields<br><br>";
echo "<table width=\"100%\" border=\"1\">";
for ($cnt1 = 0; $cnt1 < $records; $cnt1++) {
echo "<tr>";
for ($cnt2 = 0; $cnt2 < $fields; $cnt2++) {
$fieldlen = mysql_field_len($result,$cnt2);
$f = mysql_fetch_array($result);
$s = sprintf("%".$fieldlen."s",mysql_result($result,$cnt1,$cnt2));
echo "<td>$s</td>";
}
echo "</tr>";
}
echo "</table>";
}
include "functions.inc.php";
do_db_connect()
or die ("Cannot connect to db\n\n");
$query = "SELECT userName AS 'User', "
."description AS 'Statement', "
."DATE_FORMAT(date,\"%d/%m/%Y\") AS 'Date', "
."time AS 'Time' "
."FROM changes";
$result = mysql_query($query)
or die("Cannot execute query $query\n\nMysql Said".mysql_error()."\n\nPlease check and try again.");
do_it($result);
?>
to create dynamic reports from my database, but it keeps on timing out, what am I doing wrong. Or can you suggest a resource which I can use instead. Thanks in advance.
Scott K.
<?
function do_it($result) {
$fields = mysql_num_fields($result);
$records = mysql_num_rows($result);
echo "Records: $records / Fields: $fields<br><br>";
echo "<table width=\"100%\" border=\"1\">";
for ($cnt1 = 0; $cnt1 < $records; $cnt1++) {
echo "<tr>";
for ($cnt2 = 0; $cnt2 < $fields; $cnt2++) {
$fieldlen = mysql_field_len($result,$cnt2);
$f = mysql_fetch_array($result);
$s = sprintf("%".$fieldlen."s",mysql_result($result,$cnt1,$cnt2));
echo "<td>$s</td>";
}
echo "</tr>";
}
echo "</table>";
}
include "functions.inc.php";
do_db_connect()
or die ("Cannot connect to db\n\n");
$query = "SELECT userName AS 'User', "
."description AS 'Statement', "
."DATE_FORMAT(date,\"%d/%m/%Y\") AS 'Date', "
."time AS 'Time' "
."FROM changes";
$result = mysql_query($query)
or die("Cannot execute query $query\n\nMysql Said".mysql_error()."\n\nPlease check and try again.");
do_it($result);
?>
to create dynamic reports from my database, but it keeps on timing out, what am I doing wrong. Or can you suggest a resource which I can use instead. Thanks in advance.
Scott K.