I've got a set of database results where some of the columns have empty fields. I'm running this query:
SELECT * FROM `data` WHERE category = '$category' ORDER BY name
The PHP that's outputting the results is this (much simplified version):
while ($qValues = mysql_fetch_array($result)) {
if ($qValues["licence"] != "") {
$lice = 'Licence: ' . $qValues["licence"];
}
if ($qValues["publisher"] != "") {
$pub = 'Publisher: ' . $qValues["publisher"];
}
}
What's happening is, if the previous row had a publisher, but the current row has no publisher (not null, empty string) it is outputting the previous row's data.
I've no idea how this is happening because in my mind, mysql_fetch_array
has the data in a grid, and the while loop advances it's internal counter one row after another. I don't understand how one row's data could bleed over into the next row if that row contained an empty string.
What's happening here?