This code work for one selectbox and when find value he stop even if exist more column with same value. I need to work for many select box, and to populate table with all rows with same column value (value.that the user chooses with select boxes)
<?php
require('includes/config.php');
require('layout/header.php');
function get_info($db, $predmet)
{
$sql = $db->prepare("SELECT * FROM raspored WHERE predmet = :predmet");
$sql->setFetchMode(PDO::FETCH_ASSOC);
$sql->execute([':predmet' => $predmet]);
if ($row = $sql->fetch()) {
return $row;
}
return false;
}
?>
<table border="0" class="table table-hover table-striped">
<tr COLSPAN=2 BGCOLOR="#6D8FFF">
<th>ИД</th>
<th>Предмет</th>
<th>Професор</th>
<th>Ден</th>
<th>Час</th>
<th>Просторија</th>
<th>Тип</th>
</tr>
<?php
if (isset($_POST['predmet1'])) {
if ($row = get_info($db, $_POST['predmet1'])) {
echo "<tr>" .
"<td>" . $row["ID"] . "</td>" .
"<td>" . $row["predmet"] . "</td>" .
"<td>" . $row["profesor"] . "</td>" .
"<td>" . $row["den"] . "</td>" .
"<td>" . $row["chas"] . "</td>" .
"<td>" . $row["prostorija"] . "</td>" .
"<td>" . $row["tip"] . "</td>" .
"</tr>";
} else {
echo "don't exist records for list on the table";
}
}
?>
</table>
</div>
<?php
//футер
require('layout/footer.php');
?>