I want to generate a list in pdf of the passengers on a bus ride.
My problem is, that in every second cell on the right side, there is the same person from the first cell in every row.
And i want to order them with "ut_utasok_ules_pozicio" column. This means the seat number on the bus.
My code is:
`$html .= ”;
while($aa = mysqli_fetch_assoc($adat))
{
$html .= '<tr>
<td>'.$aa['ut_utasok_ules_pozicio'] . '. ' . $aa['utas_nev'] . '</td>
<td>'.$aa['ut_utasok_ules_pozicio'] . '. ' . $aa['utas_nev'] . '</td>
</tr>';
}
$html .= '</table>';`
I tried modify my sql query, but i think the problem isnt there.
2
Answers
I used Google Translate to understand your fields; it suggests that "utas név" is Hungarian for "passenger name."
In your code, you have two identical cells with identical data:
This is why you see the same content in both cells.
I think you might want to display the seat number in the first cell and the passenger name in the second cell, like this:
Regarding your comment:
it seems your records are already sorted, as the numbers from 1 to 4 appear in the correct order.
Please consider reviewing the basics of HTML. You can start here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td
I’m sure you want to display the number on the left and the name on the right. I see that PHP can retrieve data from the database correctly, it just needs adjustments in the PHP code.
As you can see from the code above, I have organized the code you created to make it easier to read, and in the future, if there is a need for corrections, it will be easier to fix.