load->view('api_view'); } function action() { if($this->input->post('data_action')) { $data_action = $this->input->post('data_action'); if($data_action == "Delete") { $api_url = "http://localhost/chess/admin/api/delete"; $form_data = array( 'id' => $this->input->post('user_id') ); $client = curl_init($api_url); curl_setopt($client, CURLOPT_POST, true); curl_setopt($client, CURLOPT_POSTFIELDS, $form_data); curl_setopt($client, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($client); curl_close($client); echo $response; } if($data_action == "Edit") { $api_url = "http://localhost/chess/admin/api/update"; $form_data = array( 'tid' => $this->input->post('tid'), 'tname' => $this->input->post('tname'), 'entry_fee' => $this->input->post('entry_fee'), 'start_date' => $this->input->post('start_date'), 'end_date' => $this->input->post('end_date'), 'win_amount' => $this->input->post('win_amount'), 'time_slot' => $this->input->post('time_slot') ); $client = curl_init($api_url); curl_setopt($client, CURLOPT_POST, true); curl_setopt($client, CURLOPT_POSTFIELDS, $form_data); curl_setopt($client, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($client); curl_close($client); echo $response; } if($data_action == "fetch_single") { $api_url = "http://localhost/chess/admin/api/fetch_single"; $form_data = array( 'tid' => $this->input->post('tid') ); $client = curl_init($api_url); curl_setopt($client, CURLOPT_POST, true); curl_setopt($client, CURLOPT_POSTFIELDS, $form_data); curl_setopt($client, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($client); curl_close($client); echo $response; } if($data_action == "Insert") { $api_url = "http://localhost/chess/admin/api/insert"; $form_data = array( 'tname' => $this->input->post('tname'), 'entry_fee' => $this->input->post('entry_fee'), 'start_date' => $this->input->post('start_date'), 'end_date' => $this->input->post('end_date'), 'win_amount' => $this->input->post('win_amount'), 'time_slot' => $this->input->post('time_slot'), 'round' => $this->input->post('round') ); $client = curl_init($api_url); curl_setopt($client, CURLOPT_POST, true); curl_setopt($client, CURLOPT_POSTFIELDS, http_build_query($form_data)); curl_setopt($client, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($client); curl_close($client); echo $response; } if($data_action == "fetch_all") { $api_url = "http://localhost/chess/admin/api"; $client = curl_init($api_url); curl_setopt($client, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($client); curl_close($client); $result = json_decode($response); $output = ''; if (is_array($result) && count($result) > 0) { foreach($result as $row) { $output .= ' '.$row->tid.' '.$row->tname.' '.$row->entry_fee.' '.$row->start_date.' '.$row->end_date.' '.$row->win_amount.' '.$row->time_slot.' Round Edit '; } } else { $output .= ' No Data Found '; } echo $output; } } } } ?>