query($sql); $output = array('data' => array()); if($result->num_rows > 0) { // $row = $result->fetch_array(); $active = ""; while($row = $result->fetch_array()) { $userid = $row[0]; // active $username = $row[1]; $button = '
'; $output['data'][] = array( // name $username, // button $button ); } // /while }// if num_rows $connect->close(); echo json_encode($output);