require_once("dbvariables.php");
This is our file containing the database information.
$sql_query = "SELECT * FROM lotto LIMIT 0,5";
This is our SQL query in this case we are only selecting 5 rows from the lotto table and we are starting at the very first row 0.
echo "<table border=\"1\" cellpadding=\"4\" cellspacing =\"4\">";
echo "<tr>";
echo "<td>Date</td><td>Ball 1</td><td>Ball 2</td><td>Ball 3</td><td>Ball 4</td>";
echo "<td>Ball 5</td><td>Ball 6</td><td>Bonus Ball</td><td>Ball Set</td><td>Machine Used</td>";
echo "</tr>";
This is just HTML output to display the headings at the top of the table.
while($row = mysql_fetch_row($result))
{
echo "<tr>";
echo "<td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td>";
echo "<td>$row[5]</td><td>$row[6]</td><td>$row[7]</td><td>$row[8]</td><td>$row[9]</td>";
echo "</tr>";
}
echo "</table>";
The lines above loop through the rows returned and output them in the table. This could be done cleverer with loops but thats another code example to come :-).
|