I have checked my Sql statement in the phpMyAdmin and it returns multiple results but when i run it as a php script it doesn't return anything. Can anyone please tell me what mistake i'm making?
<?php
require "conn.php";
/*$sqlQry = $_POST["sqlQry"];*/
$sqlQry = "SELECT bad.id, Name, Address, Latitude, Longitude, AvAge FROM baraddresses bad inner join barlivedata bld on bad.id = bld.id inner join bar_data bdt on bdt.id = bad.id";
$result = mysqli_query($conn ,$sqlQry);
$json = array();
while ($row = mysqli_fetch_array($result , MYSQL_NUM)){
$json[] = array('id' => $row[0],
'Name' => $row[1],
'Address' => $row[2],
'Latitude'=> $row[3],
'Longitude' => $row[4],
'AvAge' => $row[5]
);
}
$jsonstring = json_encode($json);
echo $jsonstring;
?>
Conn.php
<?php
/* This file allows you to connect to a database */
$db_name = "bdata";
$mysql_username = "root";
$mysql_password = "" ;
$server_name = "localhost";
$conn = mysqli_connect($server_name , $mysql_username , $mysql_password , $db_name );
/*
if($conn){
echo "true";
}
*/
?>
if (mysqli_num_rows($result) > 0) { then your while loop}else{echo "No results}