PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table budget ( id int, type int ); insert into budget values (1, 0),(2, 0),(3, 1),(4, 1),(5, 2);
Copy Clear
Copy Format Clear
<?php $btype = 1; $connection = &$mysqli; $result = []; $items = $connection->query("SELECT * FROM `budget` WHERE `type` = '".$btype."' ORDER BY `id` DESC"); foreach($items as $budget){ $arr[] = array( 'id' => $budget['id'], 'type' => $budget['type'] ); array_push($result, $arr); } echo json_encode(['success' => $result], JSON_UNESCAPED_UNICODE);
Show:  
Copy Clear