Valentin_2 0 Newbie Poster

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'); 
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.