query($sql); while($row = $db->fetch_array($rs)) { $array = array ('When' => $row["levelone"], 'Value' => $row["id"], 'Text' => htmlspecialchars($row["e_name"])); $list[] = $array; } echo json_encode($list); ?>