Autocomplete search using link
So, I create a school management system on the "Students" page. I'm looking for an autocomplete system that returns a link that will link to another page.
But you have to look at the student table to get the id for the page, so what is its viewrecord.php? id = then id of the student as well as the student name for the autocomplete system, as can be done with mysqli
I tried earlier, this is it without sql selection, it didn't work with links:
<input type="text" name="srch" id="srch" list="datalist1">
<datalist id="datalist1">
<option value="Canada">
<option value="China">
<option value="Mexico">
<option value="United Kingdom">
<option value="United States of America">
<option value="Uruguay">
</datalist>
something like this ^^^
The students table is below
id bigint(20), Auto Incrememnt And Primary
first_name varchar(255)
last_name varchar(255)
room varchar(255)
dob varchar(255)
And Finally
email varchar(255)
source to share
You may have such a workaround
Step 1:
Receive input in textbox and enter jquery which triggers keyup function
$(".search").keyup(function()
{
//your ajax call here
}
Step 2.
Inside the function, there is an ajax call to another file that asks for your input
$.ajax({
type: "POST",
url: "search.php",
data: dataString,
cache: false,
success: function(html)
{
//your action
}
});
Step 3:
In success, you can replace the result inside a div next to your search
$("#result").html(html).show();
Step 4:
Internally, search.php
you can get the input and query for the table and result, and build a hyperlink that suits your needs.
ie, user.php?id=xyz
So that you can easily go to this page
Which code would have something like
<a href="user.php?id=<?php echo $row['id']?>"><span class="name"><?php echo $username; ?></span>
</a>
Here is the source code and here is a demo I created a demo that suits your needs just for you;)
source to share