# Auto complete with json assistance

**URL:** <https://forum.kirupa.com/t/auto-complete-with-json-assistance/322674>\
**Category:** Uncategorized\
**Created:** [May 29, 2011, 10:45pm UTC](https://forum.kirupa.com/t/auto-complete-with-json-assistance/322674 "2011-05-29T22:45:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazz2000](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@mazz2000](https://forum.kirupa.com/u/mazz2000)\
**Post date:** [May 29, 2011, 10:45pm UTC](https://forum.kirupa.com/t/auto-complete-with-json-assistance/322674/1 "2011-05-29T22:45:00Z")

</div>

Hi  
I’ve been trying to customise a script i found for an autocomplete search field using a php mysql query.  
The php file is below, it’s searching mobile phone make and models, all works but when i search sam for Samsung i get nothing unless i search Sam

So my first question is can i change (with your help) the search code in the PHP to not be case sensitive?

also if i search Samsung D600 it finds the phone but i’d like it to find this phone if i just type D600, could this be a possibility with this code?

\<?php

require “dbcommon.php”;  
$result = mysql\_query(“SELECT\* FROM handsets”);  
while ($row = mysql\_fetch\_assoc($result)) {  
$handsets[] = $row[‘product\_name/handset’];  
}  
mysql\_free\_result($result);  
// check the parameter  
if(isset($\_GET[‘part’]) and $\_GET[‘part’] != ‘’)  
{  
// initialize the results array  
$results = array();

```
// search handsets
foreach($handsets as $handset)
{
	// if it starts with 'part' add to results
	if( strpos($handset, $_GET['part']) === 0 ){
		$results[] = $handset;
	}
}

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

```

}  
?\>

thanks for any help given
