Viewing file: search.php (1.61 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<html> <head> <title>pageName</title> <style type="text/css"> table { background-color: #ADD8E6; border: 1px solid black; font-family: Arial; font-size: 14px; } th { text-align: left; } </style> </head> <body> <h1>MEMBERS SEARCH</h1> <form method="post" action="search.php"> <input type="hidden" name="submitted" value="true"/> <label> Search Category: <select name="category"> <option value="first">First NAME</option> <option value="last">Last NAME</option> <option value="licencenr">Licence</option> </select> </label> <label> Search Criteria:<input type="text" name="criteria" /></label> <input type="submit" /> </form> <?php if (isset($_POST['submitted'])){ // connect to the DB include('connect.php'); $category = $_POST['category']; $criteria = $_POST['criteria']; $query = "SELECT * FROM addmember WHERE $category LIKE '%".$criteria."%'"; $result = mysqli_query ($condb, $query) or die ('error getting data from database'); $num_rows = mysqli_num_rows ($result); echo "$num_rows results found"; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { ?> <table> <tr> <td width="300" ><font face="Arial Black" size="2"><?php echo $row['last']?> <?php echo $row['rank']?></font></td> </tr> </table> <table> <tr> <td width="100"><b>Licence #</b></td> <td width="3">:</td> <td width="120"><?php echo $row['name']?></td> </tr> <tr> <td width="100"><b>Birthday</b></td> <td width="3">:</td> <td width="120"><?php echo $row['pan']?></td> </tr> <tr> <td width="100"><b>Age</b></td> <td width="3">:</td> <td width="120"><?php echo $row['occupation']?></td> </tr> <td width="120"> </td> </tr> </table> <br> <?php } } ?> </body> </html>
|