<?php
$mysqli = new mysqli('HOST', 'USER_NAME', 'PASSWORD', 'DB_NAME');
$queryResult = $mysqli->query(
'SELECT название_поля, название_поля2 FROM название_таблицы'
);
while ($rows = $queryResult->fetch_assoc()) {
$data[] = $rows;
}
echo '<pre>';
print_r($data);
echo '</pre>';
foreach ($peoples as $peopleProp) {
$count = 0;
echo '<tr>';
echo '<td>' . $peopleProp['ID'] . '</td>';
foreach ($phoneNumbers as $pnProps) {
if ($peopleProp['PHONE_NUMBER_ID'] == $pnProps['ID']) {
$count++;
echo '<td>Номер телефона ' . $pnProps['PHONE'] . '</td>';
}
}
if ($count == 0) {
echo '<td> - </td>';
}
echo '</tr>';
}