Есть вот такой код:
<?php
$sql_works = "SELECT * FROM works LEFT JOIN otdel ON works.id = otdel.id_type LEFT JOIN exam ON otdel.id_otdel = exam.id_otd ";
$result = mysql_query($sql_works);
while ($row = mysql_fetch_array($result)) {
$data[$row['name_work']][$row['name_otdel']][] = $row['name_exam'];
}
echo "<ul class='clop'>";
foreach ($data as $name_work => $otdel_array) {
echo "<li class='work_title'>" . $name_work . "</li>";
echo "<ul>";
foreach ($otdel_array as $otdel_name => $exam_names) {
echo "<li class='otdel'>" . $otdel_name . "</li>";
echo "<ul><li class='bg_li'>" . implode('</li><li class="bg_li">', $exam_names) . "</li></ul>";
}
echo "</ul>";
}
echo "</ul>";
?>
Как можно вывести все остальные данные из таблицы exam
а не только exam_name
?
Привожу код:
<?php
$sql_works = "SELECT * FROM works LEFT JOIN otdel ON works.id = otdel.id_type LEFT JOIN exam ON otdel.id_otdel = exam.id_otd LEFT JOIN child_exam ON exam.id_exam = child_exam.id_exam";
$result = mysql_query($sql_works);
while ($row = mysql_fetch_array($result)) {
if(isset($data[$row['name_work']][$row['name_otdel']][$row['name_exam']])){ $data[$row['name_work']][$row['name_otdel']][$row['name_exam']]['fields'] = $row; } $data[$row['name_work']][$row['name_otdel']][$row['name_exam']]['child'][] = $row['name_ch_exam'];
}
echo "<ul class='clop'>";
foreach ($data as $name_work => $otdel_array) {
echo "<li class='work_title'>" . $name_work . "</li>" ;
echo "<ul>";
foreach ($otdel_array as $otdel_name => $exam_names) {
echo "<li class='otdel'>" . $otdel_name . "</li>";
echo "<ul>";
foreach ($exam_names as $exam_name){ echo "<li class='bg_li'>".$exam_name['fields']['name_exam'] ." " .$exam_name['fields']['performer'] ."</li>"; echo "<ul><li>" . implode('</li><li>', $exam_names['child']) . "</li></ul>"; }
echo "</ul>";
}
echo "</ul>";
}
echo "</ul>";
?>
Не выводятся данные из child_exam
. Выдает ошибку implode() [function.implode]: Invalid arguments passed