I want to ask that while parsing an array there is no problem but when it comes to one line information I couldn't make it work.
For my JSON output:
$sql3 = mysql_query("SELECT description_fr FROM aboutUni where id = 1" );
$query = mysql_query("SELECT description FROM aboutUni WHERE id = 1");
echo '{"status":"0",';
echo '"about-uni-desc":"'.$query.'",';
echo '"about-uni-desc-fr":"'.$sql3.'",';
echo '"images": [';
An the result is for query and sql3 variables is Resource id #4 and Resource id #3 Why I can't get the exact information this comes from somewhere that I don't know
Look at the example on php.net: http://us2.php.net/mysql_query
Do this:
$sql3 = mysql_query("SELECT description_fr FROM aboutUni where id = 1" );
$query = mysql_query("SELECT description FROM aboutUni WHERE id = 1");
$result1 = mysql_fetch_assoc($sql3);
$result2 = mysql_fetch_assoc($query);
echo '{"status":"0",';
echo '"about-uni-desc":"'.$result1['description_fr'].'",';
echo '"about-uni-desc-fr":"'.$result2['description'].'",';
echo '"images": [';
If you expect multiple results from your query, then you need to iterate the result sql3 something like this:
while ($row = mysql_fetch_assoc($sql3)) {
echo '"about-uni-desc-fr":"'.$row['description_fr'].'",';
}
Recommendations:
json_encode
to return a json response$array = array( 'status' => 0, 'about-uni-desc' => $value, 'about-uni-desc-fr' => $value2 ); echo json_encode($array);