S
S
Sergey Khlopov2017-12-05 21:03:38
JavaScript
Sergey Khlopov, 2017-12-05 21:03:38

How to output an array to a table?

Hello, please tell me, I am generating a PDF document using the TCPDF library. You need to fill the table with values ​​from the array. Here is the first column. When I fill it in, the values ​​are displayed in a line, which is obvious, but I need them to be displayed in a column, I can’t figure out how to display it, please tell me.
5a26dec0b25f6940092431.png

$tbl = '
  <table cellspacing="0" cellpadding="1" border="1" align="center">
  <tr>
    <th rowspan="2">Нагрузка (эталонной гири)L,r</th>
    <th colspan="2">Показание I,r</th>
    <th colspan="2">Масса дополнительных гирь &#916;L,r</th>
    <th colspan="2">Погрешность E,r</th>
    <th colspan="2">Скорректированная погрешность Ec,r</th>
    <th rowspan="2">mpe,r</th>
  </tr>
  <tr>
    <th>&darr;</th>
    <th>&uarr;</th>
    <th>&darr;</th>
    <th>&uarr;</th>
    <th>&darr;</th>
    <th>&uarr;</th>
    <th>&darr;</th>
    <th>&uarr;</th>
  </tr>';
for($i = 0; $i < 6; $i++) {
  $tbl .= '<tr>';
  for($j = 0; $j < 10; $j++) {
    if($i == 5 && $j == 0) {
    $tbl .= '<td>'.$MAX.'</td>';
    }
    else {
    $tbl .= '<td>'.$temparray[$i][$j].'</td>';
    }
  }
  $tbl .= '</tr>';
}
$tbl .= '</table>';

I render the table like this

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Антон Неверов, 2019-09-22
@WebN00b

Первая ссылка в гугле по запросу "Slick 3d slider" - https://ru.stackoverflow.com/questions/760379/3d-%...

K
KazeZlat, 2017-12-05
@Shlop

<tr>- row, <td>- cell.
This is how the tables are set up.
What array are you outputting? Your code is correct, it's just that your array must be rotated correctly, maybe you have it distributed into columns, but you need it into rows.
In your case, you should probably $temparray[$i][$j]change to$temparray[$j][$i]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question