Autocomplete search in PHP, Mysql, Json with href Link Navigation

Explanation of code Implementation

Autocomplete search in Json

What is JSON?

JavaScript Object Notation (In sort JSON), is a lightweight data-interchange format. Json can be easily read and write by Human because it is a text format and it is completely language independent.

JSON has two working structure:

• A collection of name/value pairs.

• An ordered list of values.

Here we will use just a simple input text box to get the user input data and when user enter any word then a jquery event occurs. This jquery have autocomplete funaction. This function is responsible for autocomplete in Jquery UI. We will use a Jquery UI Custom javascript (Please do not change anything in this javascript).

This function calls an external file called global_search.php. In this file we will get the user input data and trim it. After that we will make mysql query to get related data and store it in an array. Then using json_encode method we will encode that data and print that encoded data. Here we can make a link over all data and when user clicks on any data then user will be navigate to that URL.


while($recResult = mysql_fetch_assoc($recSql)) {
  $json_arr["id"] = "".$recResult['url'].".htm";
  $json_arr["value"] = $recResult['title'];
  $json_arr["label"] = $recResult['title'];
  array_push($display_json, $json_arr);
} else {
  $json_arr["id"] = "#";
  $json_arr["value"] = "";
  $json_arr["label"] = "No Result Found !";
  array_push($display_json, $json_arr);
$jsonWrite = json_encode($display_json); //encode that search data
print $jsonWrite;

This tutorial is different because here we can learn auto complete with href navigation. This is a complete auto search tutorial where after searching user can navigate to their URL

If you have any issue with this tutorial, Please write us on comment section.

Share this Article on Social Media

All of my Scripts are ready to customized as per your requirement. Feel free to contact for script customization.

Contact me at

"Note : It will be charged as per your customization requirement :)"

Get Updates, Scripts & Other Tutorials to Directly to your Email

Over 20000+ Happy Readers already subscribed. (We don't send spam email). Every email subscriber can get our latest updates and download our 100+ scripts.