如何从数据库获取所有序列并通过JSON发回

I want all serialNo from registration table and then send it back to device. I try this:

date_default_timezone_set ('Asia/Phnom_Penh');
// Create a header with the current time
header('Last-Modified: ' . date("D, d M Y H:i:s", time()) . ' GMT+7');

$query1 = mysql_query("select serialNo from registration");
$row = mysql_fetch_array($query1);
$serialsArray = Array($row['serialNo']); 

$tag = '';
    if(!empty($_GET['passesUpadatedSince'])){
        $tag = strtotime($_GET['passesUpadatedSince']);
        error_log('Tag: ' .$tag,0);
    }

        $query1 = mysql_query("select MAX(updateTag) as updateTag from digiCardPass");
        $row1 = mysql_fetch_array($query1);
        $updateTag = $row1['updateTag'];
        error_log("get serial method");

    //if (!empty($serialsArray) && $updateTag != $tag) {
    if (!empty($serialsArray)) {

            echo json_encode(array('lastUpdated' => (string)time(), 
                       'serialNumbers' => $serialsArray)); 
    }else {
        response(204);
    }
}

?>


But when I send serial, I see only 1 serial. This is the result: May 7 17:01:05 ML-iphone-5 passd[4234] <Warning>: Get serial numbers task completed with update tag 1367920864, serial numbers ( 1 )
How can I get all serial ?

Because each device has own deviceID, so I just change :
$query1 = mysql_query("select serialNo from registration where deviceID = '$deviceID'");
and now everything works like what I want !

You should be using mysqli as the mysql_* is deprecated, but anyway...

You only see one result because you use:

$row1 = mysql_fetch_array($query1);
$updateTag = $row1['updateTag'];

You need something like this:

while ($row = mysql_fetch_row($query1))
{
    // do something sensible with each one here
    echo $row['updateTag'];
}