Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Search Engin`for entered data</title>
- </head>
- <body>
- <form action="search.php" method="post">
- <input type="text" name="results">
- <input type="submit" name="submit" value="search">
- </form>
- </body>
- </html>
- <?php
- $dbname = "My_database";
- $dbserver = "localhost";
- $user = "root";
- $password = "";
- if(isset($_POST['submit']))
- {
- $conn =new mysqli($dbserver,$user,$password,$dbname);
- $valuetosearch = $_POST['results'];
- $sql = "SELECT * FROM myguests WHERE CONCAT('id','fname','lname') LIKE '%".$valuetosearch."%'";
- $search_result = $conn->query($sql);
- }
- while($row = $search_result->fetch_assoc())
- {
- echo "<br> id: ". $row["id"]. " - Name: ". $row["fname"]. " " . $row["lname"] . "<br>";
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement