php - Add a Title and fields in a table got from mysql -


i have function returns table generated values in database. function returns table in format:

 total  ss      fai     user                            rate  99     12      87      example.of@mail.com             78  21     21      0       xxx.zzzzz@domain.com            12  35     35      0       unknown address                 16  60     60      0       002154251                       3 

here's function use:

function table($tab) {   echo '<br /><table border ="3">';   echo '<tr>';    foreach($tab[0] $cle=>$val)   {     echo "<th>".$cle."</th>";   }    echo '</tr>';    foreach($tab $cle1=>$line)   {     echo '<tr>';      foreach($line $cle2=>$val)     {       echo '<td>'.$val.'</td>';     }      echo '</tr>';   }    echo '</table><br />'; } 

i add column "type" , written in won't database.. values defined typing them. table this:

type    total   ss      fai     user                            rate kft     99      12      87      example.of@mail.com             78 vst     21      21      0       xxx.zzzzz@domain.com            12 lsq     35      35      0       unknown address                 16 ale     60      60      0       002154251                       3 

function table($tab){     $extravalue = array('kft','vst','lsq','ale');     echo '<br /><table border ="3">';     echo '<tr>';     echo '<th>type</th>';  // column heading     foreach($tab[0] $cle=>$val){         echo "<th>".$cle."</th>";     }     echo '</tr>';     $i = 0;     foreach($tab $cle1=>$line){         echo '<tr>';         echo "<td>".$extravalue[$i]."</td>";         foreach($line $cle2=>$val){             echo '<td>'.$val.'</td>';         }         echo '</tr>';         $i++;     }     echo '</table><br />'; } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -