FROM anuncios AS a JOIN motor AS m ON m.anuncio_id = a.id ';
                            break;
                    }
                    BD::conectar();
                    $result = BD::consultar("SELECT hijos FROM categorias WHERE id = '{$categoria_actual}'");
                    $row = mysqli_fetch_row($result);
                    mysqli_free_result($result);
                    $sql = empty(trim($row[0])) ? $sql_cab . "WHERE a.categoria_id2 = '{$_GET['categoria-actual']}'" : $sql_cab . "WHERE a.categoria_id2 IN ({$row[0]}) ";
                    $sql .= ' AND a.id=' . $f_rel . ' ';
                    $result = BD::consultar($sql);
                    if ($result) {
                        $data = array();
                        while ($row = mysqli_fetch_assoc($result)) {
                            $data[] = $row;
                        }
                        mysqli_free_result($result);
                        foreach ($data as &$anuncio) {
                            $anuncio['fch'] = GM_general::slugify($anuncio['titulo']) . '-gmm' . $anuncio['id'];
                            $anuncio['imagenes'] = GM_busquedas_motor::obtener_fotos_anuncio($anuncio['id']);
                        }
                        // echo ($sql);
                        echo json_encode($data);
                        BD::desconectar();
                    } else {
                        echo 0;
                    }
                }
            }
        }
    }
}
Exemple #2
0
	            <div class="grupoFichasTop gftac">';
    }
    if ($result) {
        while ($row = mysqli_fetch_assoc($result)) {
            $str .= '<div class="fichaInfo">
                    <div class="listaFichaIzq">';
            $ficha = '/' . GM_general::obtener_nombre_rr_categoria($row[$cat]) . '/' . GM_general::slugify($row['titulo']) . '-gm' . $prefijo . $row['id'] . '.htm';
            switch ($categoria) {
                case -2:
                    $img_arr = GM_busquedas_motor::obtener_fotos_anuncio($row['id']);
                    break;
                case -3:
                    $img_arr = GM_busquedas_inmo::obtener_fotos_anuncio($row['id']);
                    break;
                default:
                    $img_arr = GM_busquedas_motor::obtener_fotos_anuncio($row['id']);
                    break;
            }
            if (empty($img_arr)) {
                $img = '/img/templates/no-foto.gif';
            } else {
                $img = "/img/img_anuncios/" . $img_arr[0]['url'];
            }
            $precio = number_format($row['precio'], 0, ',', '.');
            if ($_POST['blq'] == 'ce') {
                if ($row['latitud'] != 0 && $row['longitud'] != 0) {
                    if ($row['distancia'] > 1) {
                        $distancia = number_format($row['distancia'], 0, ",", ".") . " Kms.";
                    } else {
                        if ($row['distancia'] > 0) {
                            $distancia = number_format($row['distancia'] * 1000, 0, ",", ".") . " m";
<?php

include '../BD.class.php';
include "../GM_general.class.php";
if ($_GET['anuncio']) {
    BD::conectar();
    switch ($_GET['categoria-padre']) {
        case 'inmobiliaria':
            include "../GM_busquedas_inmo.class.php";
            $imgs = GM_busquedas_inmo::obtener_fotos_anuncio($_GET['anuncio']);
            echo json_encode($imgs);
            break;
        case 'motor':
            include '../GM_busquedas_motor.class.php';
            $imgs = GM_busquedas_motor::obtener_fotos_anuncio($_GET['anuncio']);
            echo json_encode($imgs);
            break;
    }
    BD::desconectar();
} else {
    echo 0;
}