I have a search box where users can search for other users in a few types of ways, firstname, lastname, username or email within a drop down. This drop down shows the top 8 results and then I show a link at the bottom saying find more results with the bit of text they may have inputted into the search.
So for instance if I type in JOHN but only type ‘JO’ of his name this is the value $_GET[‘t’] should send through to the searchresults page. So I got as far as the link. But I just don’t know what the query should be
Show more results link
<a href='include/searchresults.php?ref=".$_GET['t']."'>Show More Results for ".$_GET['t']."</a>
SEARCHRUSULTS.PHP
if(isset($_GET['t'])){
$_GET['t'] = str_replace(" ", "", $_GET['t']);
$_GET['t'] = str_replace("%", "", $_GET['t']);
$_GET['t'] = mysqli_real_escape_string($mysqli,$_GET['t']);
if(strlen($_GET['t'])>1){
$sql="SELECT * FROM users WHERE username LIKE '%".$_GET['t']."%' OR first LIKE '%".$_GET['t']."%' OR last LIKE '%".$_GET['t']."%' OR email LIKE '%".$_GET['t']."%' ORDER BY first ASC";
$query=mysqli_query($mysqli,$sql);
$count = mysqli_num_rows($query);
if($count<=0){
echo "No results found";
}else{
echo "<table width='100%'>";
while($user_data=mysqli_fetch_array($query)){}
Try something like this, using MATCH insted of LIKE is much faster.
and set
$rowsperpageas you like.For more result page do something like this