Nel database i nomi sono elencati con la prima lettera in Maiuscolo.
Così com'è il codice php mi elenca dalla tabella "persone" i nomi dopo la digitalizzazione della seconda lettera e solo 10 risultati.
Dovrei (digitando o in minuscolo o in MAIUSCOLO) far visualizzare i nomi contenuti nel campo.
Esiste una fonzione?
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 WHERE nome LIKE '$part%' LIMIT 10");
while ($row = mysql_fetch_assoc($result)) {
$colors[]=$row['nome'];
}
mysql_free_result($result);
mysql_close($link);
$part = $_GET['part'];
$length = strlen($part);
// check the parameter
if(isset($_GET['part']) and $_GET['part'] != ” and $length > 1)
{
// 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']) === 0 ){
$results[] = $color;
}
}
// return the array as json with PHP 5.2
echo json_encode($results);
}
?>
grazie mille