Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 66447

Re: PHP Query Issue

$
0
0

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>


Viewing all articles
Browse latest Browse all 66447


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>