Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <h2>Search</h2>
- <form name="search" method="post" action="<?=$PHP_SELF?>">
- Search for: <input type="text" name="find" /> in <Select NAME="field">
- <Select NAME="field">
- <Option VALUE="fname">First Name</option>
- <Option VALUE="lname">Last Name</option>
- <Option VALUE="info">Profile</option>
- </Select>
- <input type="hidden" name="searching" value="yes" />
- <input type="submit" name="search" value="Search" />
- </form>
- <?php
- // put your code here
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "olympics";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT * FROM tasters WHERE upper($field) LIKE'%$find%'");
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_assoc($result)) {
- echo '<a href="session-details.php?id=' . $row["Number"] . '">' . $row["Taster"] . ' ' . $row["Venue"] . '</a><br>';
- }
- } else {
- echo "0 results";
- }
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement