php - 2D array in mysql query -
hi want create mysql query:
"select *, route.id id_id, profile.id profile_id route_date left join route on route_date.id_route = route.id left join profile on route.user_id = profile.id route_date.date_time <= '$hike_date_to_input_updated' , (route_date.date_time + interval (round('$start[id_id][distance_route]'/route.route_distance*route.route_time)) second) >='$hike_date_from_input_updated' , route.free >= $hike_free , route.status = '2' , route.type ='1' , route.id in (".implode(",",$searching_route_ids).") order route_date.date_time asc" problem in
route_date.date_time + interval (round('$start[id_id][distance_route]'/route.route_distance*route.route_time)) second) >='$hike_date_from_input_updated'. i need calculate +seconds if matching criteria ids in route.id(id_id) generating during select , have stored them in 2d array $start[id_id][distance_route] previous calculations. how achieve it?
doesn't matter query is, retrieve data select query in same basic way. field names, table names, etc.. might change, still use same mechanics. boils down to
$result = mysql_query($sql) or die(mysql_error()); $data = array(); while($row = mysql_fetch_assoc($result)) { $data[] = $row; } if need build multi-dimensional array retrieved data, you'd
$data[$row['field1']][$row['field2']][...etc...] = $row; ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^^ array key #1 array key #2 array keys 3..n instead. use individual values retrieved row keys in new array.
Comments
Post a Comment