php script returns object

13 views
Skip to first unread message

ABDEL ADIM ENNAJJAMI

unread,
Jun 23, 2016, 2:27:35 PM6/23/16
to thephpleague
hello guys this script : 
<?php
error_reporting(0);
include("db_config.php");

// array for JSON response
$response = array();

// get all items from myorder table
$result = mysql_query("SELECT *FROM free_lancer") or die(mysql_error());

if (mysql_num_rows($result) > 0) {
  
    $response["orders"] = array();

    while ($row = mysql_fetch_array($result)) {
            // temp user array
            $item = array();
            $item["ID_FL"] = $row["ID_FL"];
            $item["FL_LOGIN"] = $row["FL_LOGIN"];
        
            // push ordered items into response array 
            array_push($response["orders"], $item);
           }
      // success
    // $response["success"] = 1;
}
else {
    // order is empty 
      $response["success"] = 0;
      $response["message"] = "No Items Found";
}
// echoing JSON response
echo json_encode($response);

?>

has the out put : {"orders":[{"ID_FL":"1","FL_LOGIN":"e"},{"ID_FL":"7","FL_LOGIN":"FL"}]}



so i want to have only the array inside the object so i can use it with volley in android 
Reply all
Reply to author
Forward
0 new messages