query($sql)) { while ($row = mysql_fetch_assoc($result)) { $array = array ('When' => $row["levelone_id"], 'Value' => $row["id"], 'Text' => htmlspecialchars($row["en_name"])); $list[] = $array; } mysql_free_result($result); } echo json_encode($list); ?>