D
D
DjimiDjimi2018-05-13 20:38:22
PHP
DjimiDjimi, 2018-05-13 20:38:22

Why is the loop displaying the same information 3 times?

Please tell me why this code fetches data from the database 3 times

//	Вывод информации о товарах
$html = '<table border="1" width="80%" align="center" class="tableSelect">';
foreach (DataBase::getDb()->getRow('SELECT * FROM ' . Config::DB_TABLE_GOODS) as $row) {	
  $html .= '<tr>';
  $html .= '<td width="10%">' . $row['barcode_good'] . '</td> 
        <td width="50%">' . $row['name_good'] . '</td> 
        <td width="5%">' . $row['price_good'] . ' руб.</td>
        <td width="15%">' . $row['id_group'] . '</td>';
  $html .= '</tr>';
  unset($row);
}
$html .= '</table><br><br>';
echo $html;

The table has 25 elements and it outputs 135 rows.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-05-14
Alexsev @MaxGoody

Maybe because you're doing multiple SQL queries?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question