lol oh filch
this is where the dynamic piece would have helped on the saving
i would suggest to possibly alphabetize them, that is unless they are in order by id
to your query add this
order airport.airport asc, service.service asc
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
why not do the similar thing as before
loop through the results
when the airportcode changes that means you are in a new group
if in same group, loop through the services and check the appropriate box
i'm not really following the part you are having trouble with, unles you are meaning you want rows to columns? meaning one single row per airport with columns of services
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
Yeah I want there to be one row per airport and then, inside of that row, I want to list the related services, either as columns or as rows.
you are meaning sql or php?
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
will you post the structure and i get you a query?
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
the table schema, if you want you can send a backup if its small enough
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
thanks, how soon do you need it?
cool if i get back with you in the morning?
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
sure man, will work on it right after i get to work in the morning
...ahhhh, a fresh mind
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
this should do the trick, the only problem is if you ever add services, you will need to change the query to reflect that
select usr_id_users as USR_ID, airport_id_airport AS AIRPORT_ID,
a.airport_code AS AIRPORT_CODE,
max(if(service_id_service=1, 1, 0)) as JET,
max(if(service_id_service=2, 1, 0)) as GROUND,
max(if(service_id_service=3, 1, 0)) as GLYCOL
FROM userairportservices uas
INNER JOIN airport a
on a.airport_id = uas.airport_id_airport
-- change this for different users
where usr_id_users = 1
group by airport_id_airport;
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
basically there will be rows, that will be null (its set to 0 in the the if statement), because the rows are columns, if the service_id != 1 then the row will be null
therefore, the max will pull the highest, which will be 1 if the entry is there
think of it like for columns JET GROUND and GLYCOL
1 0 0
0 1 0
0 0 1
the max, allows us to group these three rows and select "1" if the service is enabled, although its in a different row
let me know if i need to explain it a little better
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143