// This will return all users in the database in a table <?php //connect to database require_once '../mysqli_connect'; //Define query $query = "SELECT firstName, lastName, email, password, streetAddress, postalCode, DOB, gender FROM users"; //execute query $response = @msqli_query($dbc, $query); //print graph if ($response) { echo '<table class="tg"> <tr> <th class="tg-9hbo">id</th> <th class="tg-9hbo">First Name<br></th> <th class="tg-9hbo">Last Name<br></th> <th class="tg-9hbo">Email</th> <th class="tg-9hbo">Password</th> <th class="tg-9hbo">Address<br></th> <th class="tg-9hbo">Postal Code<br></th> <th class="tg-9hbo">DOB<br></th> <th class="tg-9hbo">Gender</th> </tr>'; while ($row = mysqli_fetch_array($response)) { echo '<tr><td align="left">' . $row[id] . '</td><td align="left">' . $row[firstName] . '</td><td align="left">' . $row[lastName] . '</td><td align="left">' . $row[email] . '</td><td align="left">' . $row[password] . '</td><td align="left">' . $row[streetAddress] . '</td><td align="left">' . $row[postalCode] . '</td><td align="left">' . $row[DOB] . '</td><td align="left">' . $row[gender] . '</td></tr>'; } echo '</table>'; } else { echo 'No query'; echo mysqli_error($dbc); }
while ($row = mysqli_fetch_array($result)) { $facility_name = $row['facName']; $id = $row['id']; echo "ID: " . $id . ". Facility: " . $facility_name . "<br>"; } echo ' <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Search Our Records</title> </head> <p><body> <h3>Enter Facility ID</h3> <form method="post" action="cred.php" id="searchform"> <input type="text" name="facility_id"> <input type="submit" name="submit" value="Search"> </form> </body> </html> </p> '; if (isset($_POST['submit'])) { // Enter the Code you want to execute after the form has been submitted $facility_id = $_POST['facility_id']; $sql = "SELECT `facName` FROM `facilities` WHERE `id`=" . $facility_id; $result = msqli_query($conn, $sql); $facility_name = $row['facName']; echo $facility_name; // Dispaly Success or failure Message if any } else { // Display the Form and the Submit Button }