This query works, but does not display a 'no results' message. Should it be echo instead of exit on line 6?
<?php
$key = $_GET['key'];
$array = array();
$con = mysql_connect("localhost","xxx","xxx");
$db = mysql_select_db("xxx",$con);
$query = mysql_query("select * FROM byartist2columns WHERE byartistnd LIKE '%{$key}%'");
if( mysql_num_rows($query) == 0 ) exit( "No results" );
while($row=mysql_fetch_assoc($query))
{
$array[] = $row['byartist'];
}
echo json_encode($array);
?>
JAVASCRIPT
<script>
$(document).ready(function() {
$('input.typeahead').typeahead({
name: 'typeahead',
remote: 'r-search.php?key=%QUERY',
limit: 150
});
});
</script>