I”ve a table like this
global_id | auto_trans | add_drivers |child_seat | booster_seat | day
- - - - - - - - - - - - - - - -- -- - - - - - - - -- - - - - - - - -
18 2 1 5 2 2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
19 5 8 7 6 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
20 2 4 7 9 3
- - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - -
I want to display the values in a table in the below format
___________|__1_|_2_ |_3 |
| | | | |
auto_trans | 5 | 2 | 2 |
- - - - - - - - - - - - -
add_drivers | 8 | 1 | 4 |
-- - - - - - - - - - --
child_seat | 7 | 5 | 7 |
- - - - - - - - - - - - -
booster_seat| 6 | 2 | 9 |
- - - - - - - - - - - - - -
How to write loop for this?
The easy answer? By creating a loop in a loop that’ll store the value of a columnname by columnname, instead of what row it is in in the database (see below for an example if you’re in a pickle and need this solved ASAP). The correct answer, however, is that you probably need to normalise your database a little further. Although the values seem to be related, your request to print them in this way tells me your database might be a little off.