Forum Moderators: coopster
Book_num Title Price Category Abstract
b158 PHP 5 101 PHP is cool
b158 PHP 5 203 PHP is cool
b158 PHP 5 309 PHP is cool
c201 C+ 10 102 Learn C+
c201 C+ 10 212 Learn C+
C201 C+ 10 366 Learn C+
the list goes on and on..........
As you can see, the three rows of data for b158 are pretty much identical except for the Category column. Same thing with c201. So what I want to do is to create a script with PHP so that it will automatically delete the extra rows of each Book_num and merge the different Category number together. I want it to be like this:
Book_num Title Price Category Abstract
b158 PHP 5 101,203,309 PHP is cool
c201 C+ 10 102,212,366 Learn C+
I am not sure how to start the coding so any ideas would be appreciated. Thanks.
Your best bet would be to loop through the rows and monitor for a change in the primary key, building a new variable or array from the categories. Or, if you are using MySQL, you could give GROUP_CONCAT a whirl. I found a couple of old threads that may be relative:
[webmasterworld.com...]
[webmasterworld.com...]
[webmasterworld.com...]