Exemplo n.º 1
0
function getMoreImages($lastId)
{
    //$sql = "SELECT * FROM image ORDER BY id DESC LIMIT ".$lastId.", 9";
    $sql = "SELECT * FROM image WHERE id < " . $lastId . " ORDER BY id DESC LIMIT 9 ";
    $result = $GLOBALS['conn']->query($sql);
    while ($row = mysqli_fetch_assoc($result)) {
        $row = array('img_id' => $row['id'], 'img_tagline' => $row['tagline'], 'img_name' => $row['name'], 'img_description' => $row['description'], 'img_source_site' => $row['source_site'], 'photo_url' => $row['photo_url'], 'photo_thumb_url' => $row['photo_thumb_url'], 'img_source_url' => $row['source_url'], 'img_tags' => $row['tags'], 'img_category_name' => $row['category_name'], 'img_date_created' => $row['date_created'], 'img_date_modified' => $row['date_modified'], 'img_is_favourite' => $row['is_favourite'], 'img_user_id' => $row['user_id'], 'img_status' => $row['status']);
        $data[] = preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', $row);
    }
    echo json_encode($data);
}
if ($_POST['action'] == 'getImages') {
    getImages($_POST['startImages']);
} else {
    if ($_POST['action'] == "getImagesSearch") {
        imgSearch($_POST['search']);
    } else {
        if ($_POST['action'] == "catImagesSearch") {
            catImagesSearch($_POST['category']);
        } else {
            if ($_POST['action'] == "getCat") {
                getCat();
            } else {
                if ($_POST['action'] == "catDrop") {
                    getCat();
                } else {
                    if ($_POST['action'] == "getMoreImages") {
                        getMoreImages($_POST['lastId']);
                    }
                }
            }
Exemplo n.º 2
0
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
//echo "Connected successfully";
function getImages()
{
    $sql = "SELECT * FROM cars";
    $result = $GLOBALS['conn']->query($sql);
    while ($row = mysqli_fetch_assoc($result)) {
        $row = array('id' => $row['id'], 'photoName' => $row['photoName'], 'photoThumb' => $row['photoThumb'], 'photoURL' => $row['photoURL']);
        $data[] = preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', $row);
    }
    echo json_encode($data);
}
function imgSearch($photoName)
{
    $sql = "SELECT * FROM cars WHERE photoName LIKE '%" . $photoName . "%'";
    $result = $GLOBALS['conn']->query($sql);
    while ($row = mysqli_fetch_assoc($result)) {
        $row = array('id' => $row['id'], 'photoName' => $row['photoName'], 'photoThumb' => $row['photoThumb'], 'photoURL' => $row['photoURL']);
        $data[] = preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', $row);
    }
    echo json_encode($data);
}
if ($_POST['action'] == 'getImages') {
    getImages();
} else {
    if ($_POST['action'] == "getImagesSearch") {
        imgSearch($_POST['photoName']);
    }
}