I have been trying to make a php function that uses mysql to output three columns of records into a 2-D list. However when doing this, the first value in the database is skipped every time it has been run. I have read through the code again, and again and I cant seem to find any problems. The problem is not the output loop at the end as no matter where I put the echo, the first record in the database will not show up. I am using XAMPP to run the code by the way. In chrome browser.
<?php
function countHouse() {
$connection = mysql_connect('localhost','','');
mysql_select_db('sports');
$query = "SELECT ID, house, housePoints FROM sportsday WHERE housePoints != 0";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$data = array();
while($row = mysql_fetch_array($result)) {
$data[] = array($row['house'],$row['housePoints'],$row['ID']);
}
mysql_close();
return $data;
}
//Output, not a problem except $data is missing first term
$data = countHouse();
for ($i=0; $i<count($data); $i++) {
echo $data[$i][2] . " " .$data[$i][0] . $data[$i][1];?><html><br></html> <?php
}
?>