0

I have this php script set up to gather column data from my sql table and put each column's data into an array. When I echo my array it displays zero values for my array. The result is just 'Array'. I am omitting my DB connection info from the submission code, but it is successfully connected to the DB.

 //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'];


?>
Jb11281992
  • 13
  • 4

0 Answers0