I have the variable $result
that returns the result of a query.
I do a while on it and get all the info:
$total = 0;
while ($row = pg_fetch_assoc($result)) {
echo "<tr><td>".$row['no_unidade']."</td><td>".$row['no_pessoa_fisica']."</td><td style='text-align:right;'>".$row['count']."</td></tr>";
$total += $row['count'];
}
Since the no_unidade
field is the same on all rows. I decided to include this line before the while, so:
$row= pg_fetch_assoc($result);
echo '<h1 style="text-align:center;">'.$row['no_unidade'].'</h1>';
$total = 0;
while ($row = pg_fetch_assoc($result)) {
echo "<tr><td>".$row['no_unidade']." </td><td>".$row['no_pessoa_fisica']."</td><td style='text-align:right;'>".$row['count']."</td></tr>";
$total += $row['count'];
}
So I add the line that repeats at the top and ready the results below. But when I do this, the first result disappears ... And they are only listed from the second on.
How do I fix it?