0

Problem:

I have a table that prints out horizontal but I would like it to print vertical instead. Anyone who can give guidance on how this can be achieved?

PHP code

<?php
echo "<th>EKDA</th>";
echo "<th>C1</th>";
echo "<th>C2</th>";
echo "<th>C3</th>";
echo "<th>Nilai</th>";
echo "<th>Rank</th>";
echo "<tr>";
echo "<th>Vektor Eigen</th>";
for($tmbbb=0; $tmbbb<=2; $tmbbb+=1)
{
    echo "<td>$BPK2[$tmbbb]</td>";
}
echo "</tr><tr>";
echo "<th>A1</th>";
{
for($tmb=0; $tmb<=1; $tmb+=1)
    echo "<th>$TAAAC1[$tmb]</th>";
    }
    echo "</tr><tr>";
echo "<th>A2</th>";

echo "</tr>";
?>

Curent output Curent output Desired output: Desired output

Jazuly
  • 321
  • 1
  • 4
  • 15

1 Answers1

1

Try the below code :

<?php
  echo "<th>EKDA</th>";
  echo "<th>C1</th>";
  echo "<th>C2</th>";
  echo "<th>C3</th>";
  echo "<th>Nilai</th>";
  echo "<th>Rank</th>";
  echo "<tr>";
  echo "<th>Vektor Eigen</th>";
  for($tmbbb=0; $tmbbb<=2; $tmbbb+=1) {
    echo "<td>$BPK2[$tmbbb]</td>";
  }
  echo "</tr>";

  for($tmb=0; $tmb<=1; $tmb+=1) {
    if( $tmb==0 ) {
       echo "<tr><th>A1</th><th>$TAAAC1[$tmb]</th></tr>";
    }
    if( $tmb==1 ) {
      echo "<tr><th>A2</th><th>$TAAAC1[$tmb]</th></tr>";
    }
  }

?>
Abhishek
  • 1,477
  • 1
  • 10
  • 18
Khalilullah
  • 89
  • 4
  • 10
  • its work but how i add 4 more data? like this http://imgur.com/iHQnVn7 my code https://github.com/jazuly/ahp/blob/master/tes – Jazuly Mar 26 '17 at 11:24
  • Replace the `for` loop with this one- `for($tmb=0; $tmb<=1; $tmb+=1) { if( $tmb==0 ) { echo "A1$TAAAC1[$tmb]$TAAAC1[$tmb]$TAAAC1[$tmb]"; } if( $tmb==1 ) { echo "A2$TAAAC1[$tmb]$TAAAC1[$tmb]$TAAAC1[$tmb]"; } }` – Khalilullah Mar 27 '17 at 12:24