PHP Mysql - Multiple WHERE $_GET condition

Viewed 17

This wasn't inputting any data, it was just directing me to another page... Like there was a YEAR to be selected then when i click on it, this will redirect to that specified year to browse. I had some trouble adding another $_GET variable from WHERE. so what I have want to do is to display only the 'year' and 'school' from my table named "researches" via $_GET but it always give me error about Unknown column 'soict' in 'where clause'. wherein the "soict" was already had a record from my table. CODE: ###For Selecting a year

<table>
            <thead>
                <th>Year</th>
            </thead>
            <tbody>
                <?php
                    $selectQuery = "SELECT DISTINCT year, school FROM researches WHERE type='students' AND school='soict' ORDER BY year ASC";
                    $squery = mysqli_query($conn, $selectQuery);
                    while ($result = mysqli_fetch_assoc($squery)) {
                ?>
                <tr>
                  <td>
                    <?php
                         echo "<a href='researches_section.php?year=".$result['year']."&school=".$result['school']."'>";
                        echo $result['year'], '/' ,$result['school'] ; 
                    ?>
                        
                    </td>
                </tr>
                <?php
                    }
                ?>
            </tbody>
        </table>

CODE: ###Displays the specified School and Year:

<?php

include 'db_conn.php';

   $result = mysqli_query($conn,"SELECT * FROM researches WHERE school= ".$_GET['school']." && year = ".$_GET['year']." ");
   while($details=mysqli_fetch_array($result)){ ?>

    <?php
        echo "<a href='research_details.php?id=".$details['title']."'>";
        echo $details['title'];
    ?>

    <?php
        echo $details['school'];
    ?>


    <?php
        echo $details['year'];
    ?>
<?php 
}
?>
0 Answers
Related