В вашем файле несколько ошибок.Я прокомментировал это полностью, чтобы помочь другим, кто сталкивался с этим вопросом.
<?php
//Assume this line is correct and that you have a database.php file containing your log in credientials
include 'database.php';
//If Statement says - run this next piece of code if $_POST['query'] is set to something
if (isset($_POST['query']))
{
// $search_query = $_POST['query']; - Commented OUT
//This line attempts to sanatise the input from the posted data
$search_query = mysqli_real_escape_string( $_POST["query"]);
//This line constructs the whole SQL statement ( BAd methodology here, but thats a different topic)
$query = "SELECT * FROM transporter WHERE address LIKE '%".$search_query."%' LIMIT 12";
//You've commented out the next line and its of no use
// $query = "SELECT * FROM transporter WHERE address LIKE %'
//This line has a syntax error - but is also of no use - Should delete but should read $search_query = ' LIMIT 12';
//$search_query ' LIMIT 12";
/// This line queries the database
$result = mysqli_query($link, $query);
//This line declares $data will be an array
$data = array();
//If the DB returns some rows
if(mysqli_num_rows($result) > 0)
{
// While there are results
while($row = mysqli_fetch_assoc($result))
{
//add to the $data array
$data[] = $row["address"];
}
//Output $data in JSON format to be interpreted as a response from your ajax call
echo json_encode($data);
}
}
?>