I am trying to execute two simple select queries on two different tables in mysql server. This I am doing this by running a php script. Both the queries are supposed to return an empty result set. But they are returning different formats.
City table is returning a simple null value where as Dealer table is returning all columns with null values.
Output:
{**"dealer"**:[{"car_make":null,"state":null,"city":null,"company_name":null,"company_address":null,"phone":null,"mobile":null,"fax":null,"email":null,"website":null,"Data_Version":null}],**"city"**:null}
PHP Script
<?php
$data_version = 5;
require 'DbConnect.php';
$query = ("SELECT * FROM `Dealer` WHERE `Data_Version` > $data_version");
if ($query_run = mysql_query($query)){
while ($query_row = mysql_fetch_assoc($query_run)){
$out [] = $query_row;
}
}
else{
echo 'Fail';
}
$query1 = ("SELECT * FROM `City` WHERE `Data_Version` > $data_version");
if ($query_run1 = mysql_query($query1)){
while ($query_row1 = mysql_fetch_assoc($query_run1)){
$out1 [] = $query_row1;
}
}
else{
echo 'Fail';
}
$Output=array('dealer'=>$out,'city'=>$out1);
echo(json_encode($Output));
?>
So due to the varying formats i am not able to handle it. What is the reason for such varying formats? What should I do to have same kind of results??
Table Schemea
Dealer table "car_make","state","city","company_name","company_address","phone","mobile","fax","email","website","Data_Version"
City Table
city, state, Data_Version
(All fields are Varchar(50) )
Output of printing
Array ( [dealer] => Array ( [0] => Array ( [car_make] => [state] => [city] => [company_name] => [company_address] => [phone] => [mobile] => [fax] => [email] => [website] => [Data_Version] => ) )[city] => )