I want to take the result set from a query and list both the fieldnames and results. Assuming that I do not know the column names, what php code would be placed at the end of each echo statement below to show the appropriate data (column name or column value)?
$mysqli = new mysqli($svr, $usr, $pwd, $nm);
if ($mysqli->connect_error) {
trigger_error('Database connection failed: ' . $mysqli->connect_error, E_USER_ERROR);
}
$query = 'SELECT * FROM tablename';
$result = $mysqli->query($query);
while ($row = $item->fetch_assoc()) {
echo 'The columnname is: ';
echo 'The value is: ';
}
mysqli_close($mysqli);