ciao, dovrei far visualizzare solo i primi 10 risultati del campo nel database, ho provato a inserire
LIKE '$part%' LIMIT 10 ma non funziona, cosa sbaglio?


Codice PHP:
<?php

$link 
mysql_connect('localhost''db''passw');
mysql_query("SET NAMES 'utf8';");
if (!
$link) {
   die(
'Could not connect: ' mysql_error());
}
if (!
mysql_select_db("db")) {
   echo 
"Unable to select mydbname: " mysql_error();
   exit;
}

$result mysql_query("SELECT nome FROM  persone LIKE '$part%' LIMIT 10");
while (
$row mysql_fetch_assoc($result)) {
           
$colors[]=$row['nome'];
}
mysql_free_result($result);
mysql_close($link);

// check the parameter
if(isset($_GET['part']) and $_GET['part'] != '')
{
    
// initialize the results array
    
$results = array();

    
// search colors
    
foreach($colors as $color)
    {
        
// if it starts with 'part' add to results
        
if( strpos($color$_GET['part']) === ){
            
$results[] = $color;
        }
    }

    
// return the array as json with PHP 5.2
    
echo json_encode($results);
}
?>