Max Resnikoff wrote:
The Get Clause is coming from a URL variable.
But presumably you are clicking the 'search' submit button of a 'search input form field' not a url link, right?
Like:
<?php
// connect to database
$conn = new mysqli('localhost' , 'username' , 'password' , 'database_name'); ?>
<?php
if(isset($_POST['txt_search'])) {
$searchword = $_POST['txt_search'];
$search_query = $conn->query("SELECT * FROM prod_book WHERE username LIKE '%".$searchword."%' OR firstname LIKE '%".$searchword."%' OR lastname LIKE '%".$searchword."%' OR email LIKE '%".$searchword."%' ");
// count no of rows
$numRows = $search_query->num_rows;
}
?>
<!DOCTYPE html>
<head>
<meta charset="UTF-8" />
<title>Search</title>
</head>
<body>
<form name="search" method="post" action="">
<label for="search_text">Text Search<br>
<input type="text" name="txt_search" >
</label>
<input type="submit" name="submit" value="submit"></td>
</form>
<?php while($row = $search_query->fetch_assoc()) { ?>
<?php echo $row['username']; ?>
<?php } ?>
</body>
</html>