0

Hi all,
I am a php rookie. I like to get a PHP function returning an array which gets a string(search query) and db results(an array) as arguments. This array should be sorted in ascending (alphabetical) order with search query positions.
I tried of querying the results but i struck up with sorting with search query positioning.
My db Array()
{
Hussain,Dalton,Zaheerus,beltwood,usher,johnny,walker,
}
My snippet

function getSearchRecords  ($string){
         $listRecords=array();

        $query="select name,member_id from member_details where name like '%$string%' order by name";
        $queryResult =  self::DbExecuteQuery($query);
        while($getRecords = self::DbFetchAssoc($queryResult)){
			array_push($listRecords,$getRecords);
			}
	return $listRecords;

$string="us";
will return hussain,usher,zaheerus (in this order).
but i need this function to return
usher [position of search query is at first]
Hussain
zaheerus[position of search query is at last]

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by pritaeas
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.