lundi 4 septembre 2017

PHP: Trying to Filter Database information in a table using a combo-box

So I am trying to sort information based the selected item in the combobox. I am familiar with parts of PHP but still learning.

I was able to fill the combo box with the 'Brand_Name' Column information from my DB.

This is my current output: enter image description here

It is not filtering though, it is just listing all items in the DB

See code below:

<?php
$hostname = "localhost";
$username = "root";
$password = "root";
$databaseName = "Clients";
$connect = mysqli_connect($hostname, $username, $password, $databaseName);
$queryDropdown = "SELECT * FROM `Brands` WHERE 1";
$result = mysqli_query($connect, $queryDropdown);
$queryGrid = "SELECT * FROM `Brands` ";
$SearchResult = mysqli_query($connect, $queryGrid);
?>
<html>
<head>
    <title>PokerPass</title>
      <link rel="stylesheet" type="text/css" href="styles/Main.css">
      <link rel="stylesheet" type="text/css" href="styles/ComboBox.css">
      <link rel="stylesheet" type="text/css" href="styles/TableGrid.css">
</head>
<body >
    <div id="Container" class="Container">
        <div id="Header" class="Header">

        </div>
        <div id="Body" class="Body">
            <div name="start" id="Filter_Bar" class="Filter_Bar">
                <select class="soflow" id="soflow" Size="1">
                  <?php while($row1 = mysqli_fetch_array($result)):; ?>
                  <option><?php echo $row1[1]; ?></option>
                <?php endwhile; ?>
                </select>
                <button class="Submit" ><span><strong>Search<strong></span></button>
                <!--<input class="Submit" type="submit" name="search" value="Search </span>">-->
            </div>
            <div id="Data_Grid" class="Data_Grid">
                  <table>
                    <tr>
                      <th>Server ID</th>
                      <th>Client</th>
                      <th>Operator</th>
                      <th>Username</th>
                      <th>Password</th>
                    </tr>
                    <?php while ($row = mysqli_fetch_array($SearchResult)):; ?>
                    <tr>
                      <td><?php echo $row['ServerID']; ?></td>
                      <td><?php echo $row['Brand_Name']; ?></td>
                      <td><?php echo $row['Operator_Name']; ?></td>
                      <td><?php echo $row['Username']; ?></td>
                      <td><?php echo $row['Password']; ?></td>
                    </tr>
                    <?php endwhile; ?>
                  </table>
            </div>
        </div>
        <div id="Footer" class="Footer">

        </div>
    </div>
</body>
</html>

Aucun commentaire:

Enregistrer un commentaire