为什么我的数组没有返回值?

时间:2016-01-13 01:53:20

标签: php sql

我设置了这个php脚本来从我的sql表中收集列数据并将每个列的数据放入一个数组中。当我回显我的数组时,它显示我的数组的零值。结果只是'数组'。我从提交代码中省略了我的数据库连接信息,但它已成功连接到数据库。

 //Connecting to the DB
$link = mysql_connect(DB_Host, DB_User, DB_Password);

if (!$link) {
    die('Could Not Connect: ' . mysql_error());
}

$db_selected = mysql_select_db(DB_Name, $link);

if (!db_selected) {
    die('Can\'t use ' . DB_Name . ': ' . mysql_error());
}

//Putting job submission address column into an array
$result_while = mysql_query("SELECT address 
  FROM jobsubmission");

$client_array = array();
while ($row2 = mysql_fetch_assoc($result_while)) {
$client_array[] = $row2['address'];
}

echo $client_array;

//Putting driver submission address column into an array
$result_while2 = mysql_query("SELECT address 
    FROM DriverInformation");

$driver_array = array();
while ($row3 = mysql_fetch_assoc($result_while2)) {
$driver_array[] = $row3['address'];
}

//replaces space with "+" sign for concetenation
$address1 = str_replace(' ', '+', $submission_array);
$address2 = str_replace(' ', '+', $driver_array);

//Google Distance Matrix API string--Sends all informtion through the
 API and performs calculation
$url = "https://maps.googleapis.com/maps/api/distancematrix/json?
origins=$address1&destinations=$address2&mode=driving&language=English-      
en&key=APIKEY";

//Return of API data--formatted to just display the distance of quickest 
route
$json = file_get_contents($url); // get the data from Google Maps API
$result = json_decode($json, true); // convert it from JSON to php array
$results_submission = $result['rows'][0]['elements'][0]['distance']['text'];


?>

0 个答案:

没有答案