function search() { include_once "course_outline.php"; $obj = new course_outline(); $txt = $_REQUEST['search']; if (!$obj->search($txt)) { echo '{"result":0, "message":"Searched Item does not exists"}'; return; } $row = $obj->fetch(); echo '{"result":1,"outlines":['; while ($row) { echo json_encode($row); $row = $obj->fetch(); if ($row) { echo ","; } } echo "]}"; }