connect(); $surveys = new Surveys($db); $surveys->pid = $data->pid; $result = $surveys->getVendorList(); $vendorsList = array(); $tempObject = new stdClass(); $tempObject->data = array(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { extract($row); if ($cid) { $item = array( "cid" => $cid, "name" => $name, "open" => (int)$open, "complete" => (int)$complete, "screenout" => (int)$screenout, "quotafull" => (int)$quotafull, "total" => (int)$total, "started" => (int)$started, ); array_push($tempObject->data, $item); } } echo json_encode($tempObject);