I have only dealt with one-to-one relationships in php so far, but I am stuck in a problem that is related to the one-to-many relationship. I sat on this for several days with no luck, so I desperately need someone to step in and show me the solution before I go crazy.
My database has a number of URLs that are retrieved using a SELECT query along with various other fields from different tables. Each url has at least one category associated with it, but can have several categories. Therefore, in my results, I could see something similar to this:
link_id = 3 url= 'http://www.somesite1.com' category = 'uncategorised'
link_id = 4 url= 'http://www.somesite2.com' category = 'travel'
link_id = 4 url= 'http://www.somesite2.com' category = 'fun'
link_id = 4 url= 'http://www.somesite2.com' category = 'misc'
link_id = 3 url= 'http://www.somesite3.com' category = 'uncategorised'
I have this to work. When I scroll and print them using a while loop and mysql fetch, the result looks exactly the same as above. This is great, except that I need it to read something like:
link_id = 4 url = 'http://www.somesite2.com' category = 'travel fun misc'
So, so that all categories for each URL are somehow combined as they print. My first attempt made me try the nested while loop, but that didn't work, and I'm not sure how possible this is. Also, I am wondering if I might need a multidimensional array (a complete hunch, I never had to use it before).
, , , , - -, . , .
?