Ejemplo n.º 1
0
function getHandler()
{
    if (isset($_GET['deleteId'])) {
        //Hack for DELETE
        deleteHandler();
    } elseif (isset($_GET['id'])) {
        //Get with id
        $id = $_GET['id'];
        $query = "SELECT * FROM news WHERE id = '{$id}' LIMIT 1";
        $result = $mysqli->query($query) or die($mysqli->error . __LINE__);
        $arr = array();
        if ($result->num_rows > 0) {
            while ($row = $result->fetch_assoc()) {
                $arr[] = $row;
            }
        }
        # JSON-encode the response
        echo $json_response = json_encode($arr);
    } else {
        //Get List
        $query = "SELECT * FROM news";
        $result = $mysqli->query($query) or die($mysqli->error . __LINE__);
        $arr = array();
        if ($result->num_rows > 0) {
            while ($row = $result->fetch_assoc()) {
                $arr[] = $row;
            }
        }
        # JSON-encode the response
        echo $json_response = json_encode($arr);
    }
}
Ejemplo n.º 2
0
<?php

require_once 'appquery.php';
if (is_ajax()) {
    if (isset($_POST['type']) && !empty($_POST['type'])) {
        $action = $_POST['type'];
        switch ($action) {
            case 'addItem':
                echo addItemHandler();
                break;
            case 'updateItem':
                echo updateApp($_POST);
                break;
            case 'delete':
                echo deleteHandler($_POST['appID']);
                break;
        }
    } else {
        if (isset($_GET['type']) && !empty($_GET['type'])) {
            $action = $_GET['type'];
            switch ($action) {
                case 'category':
                    categoryHandler();
                    break;
                case 'apps':
                    appsHandler();
                    break;
                case 'app':
                    appHandler();
                    break;
                case 'report':