In the row of the table I need to set two parameters: data-id
and data-name
, the data-name
works for me in the code. But the data-id
parameter can not be determined. Tell me please.
<div class="ok"> <? $translates = [ 'id' => 'Id', 'oblastnazn' => 'Область назначения', 'proizvoditel' => 'Производитель', 'name1' => 'Наименование', 'categ' => 'Категория', 'tsokol' => 'Цоколь', 'sklad' => 'Наличие на складе', 'svetpotok' => 'Световой поток', 'colorsveh' => 'Цвет свечения' ]; $fields = array_keys($translates); $s = "SELECT %s FROM table"; $sql = sprintf($s, implode(',', $fields)); /** @var PDOStatement $stmt */ $stmt = $dbh->query($sql); $stmt->setFetchMode(\PDO::FETCH_ASSOC); while ($row = $stmt->fetch()) { foreach ($translates as $field=>$name) { print "<div class='tab'>"; print "<table>"; print "<thead>"; print "<tr>"; print "<th style='width: 180px; height: 50px;'><center>$name</center></th>"; print "</tr>"; print "</thead>"; echo "<br>"; print "<tr >"; print "<td class='chenge' style='width: 180px; height: 50px;' data-id='' data-name='$field' >"; print $row[$field]; print "</td></tr></table></div>"; } } ?> </div>
print "<td class='chenge' style='width: 180px; height: 50px;' data-id='' data-name='$field' >";
print "<td class='chenge' style='width: 180px; height: 50px;' data-id='' data-name='$field' >";
? Apparently thedata-id
empty. - MikielD.