Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require 'dbconnect.php';
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Untitled Document</title>
- </head>
- <body>
- <form name="formbrowseone" action="" method="POST" enctype="multipart/form-data">
- <input type="text" name="query" />
- <input type="submit" value="Search" />
- </form>
- <?php
- if (isset($_POST['query'])) {
- echo '<title>Search results</title>';
- $search = '%' . $_POST['query'] . '%';
- $newsearch = filter_var($search, FILTER_SANITIZE_STRING);
- $query = "SELECT * FROM useradvert WHERE adtitle LIKE ?";
- $select = $conn->prepare($query);
- $select->bind_param('s', $newsearch);
- $select->execute();
- $result = $select->get_result();
- if ($result->num_rows($result) > 0) { // updated
- WHILE ($row = $result->fetch_assoc()){
- echo $row['adtitle'];
- }
- } else {
- // if there is no matching rows do following
- echo "No results";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement