Ajax JSON传递多个变量

Hello guys i am new to both ajax and JSON and i have followed this guide on making a jquery slider and getting some result from DB it is working but right now i can only get one result from the slider range but i want to get all results from that range so i need to pass more then one result variable from my php and cant seem to get it to work i have included my code below

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>

<script src="slider.js"></script>
<link rel="stylesheet" href="style.css" type="text/css">
</head>

<body>
<div>
<span id="deal_min_price"></span>
<span id="deal_max_price" style="float: right"></span>
<br /><br />
<div id="slider_price"></div>
<br />
<span id="number_results"></span> Abonnementer fundet
</div>
</body>
</html>

$(document).ready(function() 
{
$( "#slider_price" ).slider({

            range: true,

            min: 0,
            max: 349,

            step:1,
            values: [ 0, 349 ],


            slide: function( event, ui ) {
                $( "#deal_min_price" ).text(ui.values[0] + "KR");
                $( "#deal_max_price" ).text(ui.values[1] + "KR");
            },
            stop: function( event, ui ) {
                var dealsTotal = getDeals(ui.values[0], ui.values[1]);
                $("#number_results").text(dealsTotal);
            },
});
$("#deal_min_price").text( $("#slider_price").slider("values", 0) + "KR");
$("#deal_max_price").text( $("#slider_price").slider("values", 1) + "KR");  
});
function getDeals(min_price, max_price)
{

var numberOfDeals = 0;


$.ajax(
{
    type: "POST",
    url: 'deals.php',
    dataType: 'json',
    data: {'minprice': min_price, 'maxprice':max_price},
    async: false,
    success: function(data)
    {
        numberOfDeals = data;
    }
});
return numberOfDeals;
}

PHP:

<?php


 $result = 0;


 define('MYSQL_HOST',     'db564596075.db.1and1.com');
 define('MYSQL_USER',     'dbo564596075');
 define('MYSQL_PASSWORD', '12345678');
 define('MYSQL_DB',       'db564596075');


try 
    {
    $dbh = new PDO('mysql:host='.MYSQL_HOST.';dbname='.MYSQL_DB, MYSQL_USER, MYSQL_PASSWORD);

    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $dbh->setAttribute(PDO::ATTR_PERSISTENT, true);
    $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
    $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
} 

catch (PDOException $e) 
{
echo 'Fejk: ' . $e->getMessage() . '<br/>';
}


if(isset($_POST['minprice']) && isset($_POST['maxprice']))
{

$minprice   = filter_var($_POST['minprice'] , FILTER_VALIDATE_INT);  
$maxprice   = filter_var($_POST['maxprice'] , FILTER_VALIDATE_INT); 
$query = '
        SELECT 
        *
        FROM
            mobilabonnement
        WHERE
            Prisprmdr
        BETWEEN 
            :minprice 
        AND
            :maxprice
                    ';

$stmt = $dbh->prepare($query);
try
{
    $stmt->bindParam(':minprice', $minprice);
    $stmt->bindParam(':maxprice', $maxprice);
    $stmt->execute();
}
catch (PDOException $e)
{
    print($e->getMessage());
    die;
}

$row = $stmt->fetch(PDO::FETCH_ASSOC);
$result = $row['Selskab'];
}
if ($result == true)
{
echo json_encode($result);
 }

 else{
 echo json_encode(0);
 }


?>

Here is why You got only Selskab - $result = $row['Selskab'];

Try that:

$row = $stmt->fetch(PDO::FETCH_ASSOC);
$result = $row;

if ($result)
{
   echo json_encode($result);
}

else
{
  echo json_encode(0);
}

You need to loop over all the results or use PDO::fetchAll, if you want all the columns you also need to use the whole row not just Selskab:

$result = array();
while (false !== ($row = $stmt->fetch(PDO::FETCH_ASSOC))) {
   $result[] = $row;
}

if (count($result)
{
   echo json_encode($result);
} else{
  echo json_encode(0);
}

OR using PDO::fetchAll:

$result = $stmt->fetchAll(PDO::FETCH_ASSOC);

if (count($result)
{
   echo json_encode($result);
} else{
  echo json_encode(0);
}

However it also seems you really only want Selskab and id as opposed to all of the columns and in that case you should probably adjust your query as well:

SELECT id, Selskab
FROM  mobilabonnement
WHERE Prisprmdr BETWEEN :minprice AND :maxprice