Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $database = "abc";
- $dblink = mysqli_connect($servername,$username,$password,$database);
- if(isset($_POST['submit'])) {
- if($_POST['select']=='all_records') {
- $query = "SELECT Kod_Dorm
- FROM dorm
- ";
- }
- elseif($_POST['select']=='A302') {
- $query = "SELECT Kod_Dorm
- FROM dorm
- WHERE Kod_Dorm = 'A302'";
- }
- elseif($_POST['select']=='A303') {
- $query = "SELECT Kod_Dorm
- FROM dorm
- WHERE Kod_Dorm = 'A303'";
- }
- $results = mysqli_query($dblink, $query) or die (mysqli_error());
- }
- echo "<table>"; // start a table tag in the HTML
- while($row = mysqli_fetch_array($results)){ //Creates a loop to loop through results
- echo "<tr><td>".$row['Kod_Dorm']."</td></tr>"; //$row['index'] the index here is a field name
- }
- echo "</table>"; //Close the table in HTML
- ?>
- <form class="filteroption" action="" method="post">
- <select class="select" name="select">
- <option value ="all_records" selected="selected">All records</option>
- <option value ="A302" >A302</option>
- <option value ="A303" >A303</option>
- </select>
- <input class="" type="submit" name="submit" value="submit">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement