0

I created this script to sync with my android app. If a user will use the app, the only outputs that will be shown is the only shop that is open between some specific times.

This is my php script. I want to initialize the condition here...

require_once('db.php');


$query = "SELECT s_iD, s_name,s_contNo,s_lat,s_long FROM tbl_shop WHERE 
s_status='Confirmed' and act_stat='Active'";

$result = mysqli_query($conn,$query);
$arrayResult = array();

while ($row = mysqli_fetch_array($result)){
array_push($arrayResult,array("id"=>$row['s_iD'],"shopName"=>$row['s_name'],"shopContact"=>$row['s_contNo'],"latitude"=>$row['s_lat'],
    "longitude"=>$row['s_long']));
}


echo json_encode(array("result"=>$arrayResult));

mysqli_close($conn);

?>

...so that the only output(array) that will be called in the android app is the final result of the condition.

This is table of shop

table of shop

I'm still a new in php and android, so I don't know what code should I write to make this a possibility.

Cross
  • 3
  • 4
  • It might just be me but I'm not getting the point of your question. You want to know how to modify the query to return the proper shops? You want to get advice on how to pass the data? Your code does not show me what you want to change. There is no error and a seemingly valid sql query. If you want to filter rows based on a time between `s_tstart` and `s_tend` I'm wondering how they look like because your database picture only tells me that they are text which can be anything. – chilly Sep 24 '17 at 11:59
  • I want to show the data between s_tstart and s_tend based on server time. I changed s_tstart and s_tend data type to time recently. I don't know where to write the condition. – Cross Sep 24 '17 at 13:57
  • if you want to have the condition in your sql it would go into your `where` condition. see this question: https://stackoverflow.com/questions/3822648/how-do-i-query-between-two-dates-using-mysql – chilly Sep 24 '17 at 17:25
  • I think the condition should be done inside the while ($row = mysqli_fetch_array($result)){ }. I tried many algorithms, and all of them didn't work. – Cross Sep 24 '17 at 17:29

0 Answers0