MYSQL and Array with PHP to create a tag cloud

advertisements

I'm trying to make a tag cloud for every user in own page, I'm using PHP5 and Mysql, My table is named "tags" and I want to make a array but in short way. The table like below,

The array can be like for user1 array={[car,1],[cat,null],[pen,1],[dvd,1],[cd,null]}

  Username    totaltag   tag1 tag2 tag3 tag4 tag5
  admin       5          car  cat  pen  dvd  cd
  user1                  1         1    1
  user2                  1    2    12        1
  user3                  3    2         10   1


Better do this:

Username     Tag
user1        car
user1        pen
user1        cd
user2        car
user2        cat