views:

64

answers:

2

Hi,

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
A: 

Better do this:

Username     Tag
user1        car
user1        pen
user1        cd
user2        car
user2        cat
Sjoerd
Since in the original example users can have several times the same tag, I guess it's not the best solution
Kaaviar
A: 
<?php
            $final="SELECT * FROM tags";
            $resultfinal = mysql_query($final);
            if (!$resultfinal) { error('A database error occurred while checking your ');
                }

/* get column metadata */
$i = 0;
while ($i < mysql_num_fields($resultfinal)) {

    $meta = mysql_fetch_field($resultfinal, $i);
    if (!$meta) {
        echo "No information available<br />\n";
    }
    $denetim="$meta->name";
        if ($i>3){
             $arrtag = "SELECT * FROM tags WHERE email = 'host'";
             $arrtagson = mysql_query($arrtag);
             $arrtagbilgi = mysql_result($arrtagson,0,$denetim);

             $arrcount = "SELECT * FROM tags WHERE email ='user1'";
             $arrcountson = mysql_query($arrcount);
             $arrcountbilgi = mysql_result($arrcountson,0,$denetim);
             echo $i."-";
             echo $arrtagbilgi."=>";
             echo $arrcountbilgi."<br />";

    $arr[$arrtagbilgi] = $arrcountbilgi;
        }
    $i++;
}
    ?>    
asilloo