I’m trying to return the last 10 records from my database and display them on a web page. The code I have below only returns one record, does anyone know where I’m going wrong? I’ll tidy it up later with a table, for the moment I just need the last 10 records.
The name of the table is “devel” and the column names are: id, STATION, REASON_CODE, ERROR, WEEK, COMMENT, DOWNTIME, DATE
$dbc = mysqli_connect(‘xxxx’, ‘xxxx’, 'xxxx', ‘xxxx’)
or die('Error connecting to MySQL server.');
$query = "SELECT * FROM devel ORDER BY id DESC LIMIT 10";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
while($record = mysqli_fetch_array($result)){
echo $record['id']. " " .$record['STATION'] . " " . $record['REASON_CODE'] . " " . $record['ERROR']. " " .$record['WEEK'] . " " .$record['COMMENT'] . " " .$record['DOWNTIME'] . " " .$record['DATE'];
echo "<br /";
}