I want to get all of array value with ajax which that is coming from MySQL. I can't get all of result. I can get only 1 result.
My JQuery codes are:
$("input.input-search").keyup(function(){
    var name = $(this).val();
    if(name !='')
    {
        $.ajax({
            type: 'post',
            url: 'ajax.php?bol=search',
            data: {'name':name},
            dataType: 'json',
                success: function(val)
                {    
                     x = val.length;
                     for (i = 1; i<=x; i++){
                        $(".search-result").html(val[i].user+' * '+x);
                    }
                },
                error: function(name){
                $(".search-result").html("Nəticə yoxdur...");
                }
            });
    }
});
PHP Codes are:
case "search":
$name = trim($_POST['name']);
$q = mysql_query("SELECT * FROM `users` WHERE `user` LIKE '%".$name."%' ORDER by id;");
if(mysql_affected_rows() > 0){
    while($arr = mysql_fetch_array($q)){
        $array[] = $arr;
}
    echo json_encode($array);
}
break;
 
     
    