Hello,
Here is a snip of my code and although the mysql connection work and even the $num calcullate the numrows work as the tables gets created unfortunately no data gets populated, can any one one advise.
1 - mysql_connect (OK)
2 - mysql_select_db (OK)
3 - mysql_numrows (OK)
4 - table gets created based on $max even but no data get populated, please help.
All this goes inside a html page!
include 'config.php';
mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die('Could not connect: ' . mysql_error());
$query="SELECT name,correct,wrong,percentage,level,date FROM stats ORDER BY correct DESC LIMIT $max";
if (!$query) {
die('Invalid query: ' . mysql_error());
}
$result=mysql_query($query);
$num=mysql_numrows($result);
?>
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td><font face="Arial, Helvetica, sans-serif">Name</font></td>
<td><font face="Arial, Helvetica, sans-serif">Correct</font></td>
<td><font face="Arial, Helvetica, sans-serif">Wrong</font></td>
<td><font face="Arial, Helvetica, sans-serif">Percent</font></td>
<td><font face="Arial, Helvetica, sans-serif">Level</font></td>
<td><font face="Arial, Helvetica, sans-serif">Date</font></td>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"field1");
$f2=mysql_result($result,$i,"field2");
$f3=mysql_result($result,$i,"field3");
$f4=mysql_result($result,$i,"field4");
$f5=mysql_result($result,$i,"field5");
$f6=mysql_result($result,$i,"field6");
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f6; ?></font></td>
</tr>
<?php
$i++;
}
mysql_close();
?>