Skip to main content
se añadieron 1830 caracteres en el cuerpo
Origen Enlace
Carlos
  • 421
  • 3
  • 17

Este es el siguiente codigo que de la misma forma quiero que respete la condición inmobiliaria_inmobiliaria = 7

<?php
$users = [];
if (
    !empty($_GET["estatus_id"])
    || !empty($_GET["kind_id"])
    || !empty($_GET["priority_id"])
    || !empty($_GET["start_at"])
    || !empty($_GET["finish_at"])
) {
    $sql = "select * from v_cita_completo ";
    $where = [];
    if (!empty(["estatus_id"])) {
        $where[] = "estatus_id = '" . mysqli_real_escape_string($con, $_GET["estatus_id"]) ."'";
    }

    if (!empty(["kind_id"])) {
        $where[] = "kind_id = '" . mysqli_real_escape_string($con, $_GET["kind_id"]) . "'";
    }


    if (!empty($_GET["priority_id"])) {
        $where[] = " priority_id = '" . mysqli_real_escape_string($con, $_GET["priority_id"]) . "'";
    }



    if (!empty($_GET["start_at"]) && !empty($_GET["finish_at"])) {
        $where[] = "created_at BETWEEN '"
            . mysqli_real_escape_string($con, $_GET["start_at"])
            . " 00:00:00' AND '"
            . mysqli_real_escape_string($con, $_GET["finish_at"])
            . " 23:59:59'"
        ;
    }
    if (count($where) > 0) {
        $sql .= ' WHERE ' . implode(' AND ', $where);
    }
    $users = mysqli_query($con, $sql);

} else {
    $users = mysqli_query($con, "select * from v_cita_completo  where inmobiliaria_inmobiliaria = 7");
}
if ($users === false) {
    die('Error SQL: ' . mysqli_error($con));
}



if(@mysqli_num_rows($users)>0){
                                // si hay reportes
                                $_SESSION["report_data"] = $users;
                            ?>

Este es el siguiente codigo que de la misma forma quiero que respete la condición inmobiliaria_inmobiliaria = 7

<?php
$users = [];
if (
    !empty($_GET["estatus_id"])
    || !empty($_GET["kind_id"])
    || !empty($_GET["priority_id"])
    || !empty($_GET["start_at"])
    || !empty($_GET["finish_at"])
) {
    $sql = "select * from v_cita_completo ";
    $where = [];
    if (!empty(["estatus_id"])) {
        $where[] = "estatus_id = '" . mysqli_real_escape_string($con, $_GET["estatus_id"]) ."'";
    }

    if (!empty(["kind_id"])) {
        $where[] = "kind_id = '" . mysqli_real_escape_string($con, $_GET["kind_id"]) . "'";
    }


    if (!empty($_GET["priority_id"])) {
        $where[] = " priority_id = '" . mysqli_real_escape_string($con, $_GET["priority_id"]) . "'";
    }



    if (!empty($_GET["start_at"]) && !empty($_GET["finish_at"])) {
        $where[] = "created_at BETWEEN '"
            . mysqli_real_escape_string($con, $_GET["start_at"])
            . " 00:00:00' AND '"
            . mysqli_real_escape_string($con, $_GET["finish_at"])
            . " 23:59:59'"
        ;
    }
    if (count($where) > 0) {
        $sql .= ' WHERE ' . implode(' AND ', $where);
    }
    $users = mysqli_query($con, $sql);

} else {
    $users = mysqli_query($con, "select * from v_cita_completo  where inmobiliaria_inmobiliaria = 7");
}
if ($users === false) {
    die('Error SQL: ' . mysqli_error($con));
}



if(@mysqli_num_rows($users)>0){
                                // si hay reportes
                                $_SESSION["report_data"] = $users;
                            ?>

Revertido a la revisión 3
Origen Enlace
Triby
  • 25.2k
  • 3
  • 18
  • 36
<?php
    if($action == 'ajax'){
        // escaping, additionally removing everything that could be (html/javascript-) code
         $q = mysqli_real_escape_string($con,(strip_tags($_REQUEST['q'], ENT_QUOTES)));
          $aColumns = array('inmobiliaria_name', 'colonia', 'direccion', 'ubicacion', 'zona', 'inmueble_name', 'expediente');//Columnas de busqueda
         $sTable = "v_inventario_inmueble_completo ";
         $sWhere = "where inmobiliaria = 7";
        if ( $_GET['q'] != "" )
        {
            $sWhere .= " AND"WHERE (";
            for ( $i=0 ; $i<count($aColumns) ; $i++ )
            {
                $sWhere .= $aColumns[$i]." LIKE '%".$q."%' OR ";
            }
            $sWhere = substr_replace( $sWhere, "", -3 );
            $sWhere .= ')';
        }
        $sWhere.=" order by id desc";
         include 'pagination.php'; //include pagination file
        //pagination variables
        $page = (isset($_REQUEST['page']) && !empty($_REQUEST['page']))?$_REQUEST['page']:1;
        $per_page = 8; //how much records you want to show
        $adjacents  = 4; //gap between pages after number of adjacents
        $offset = ($page - 1) * $per_page;
        //Count the total number of row in your table*/
        $count_query   = mysqli_query($con, "SELECT count(*) AS numrows FROM $sTable  $sWhere");
        $row= mysqli_fetch_array($count_query);
        $numrows = $row['numrows'];
        $total_pages = ceil($numrows/$per_page);
        $reload = './expences.php';
         $sql="SELECT * FROM  $sTable $sWhere LIMIT $offset,$per_page";
        $query = mysqli_query($con, $sql);
        if ($query === false) {
            die('Error SQL: ' . mysqli_errror($con));
        }
        //loop through fetched data
       
            
            ?>
<?php
    if($action == 'ajax'){
        // escaping, additionally removing everything that could be (html/javascript-) code
         $q = mysqli_real_escape_string($con,(strip_tags($_REQUEST['q'], ENT_QUOTES)));
          $aColumns = array('inmobiliaria_name', 'colonia', 'direccion', 'ubicacion', 'zona', 'inmueble_name', 'expediente');//Columnas de busqueda
         $sTable = "v_inventario_inmueble_completo ";
         $sWhere = "where inmobiliaria = 7";
        if ( $_GET['q'] != "" )
        {
            $sWhere .= " AND (";
            for ( $i=0 ; $i<count($aColumns) ; $i++ )
            {
                $sWhere .= $aColumns[$i]." LIKE '%".$q."%' OR ";
            }
            $sWhere = substr_replace( $sWhere, "", -3 );
            $sWhere .= ')';
        }
        $sWhere.=" order by id desc";
         include 'pagination.php'; //include pagination file
        //pagination variables
        $page = (isset($_REQUEST['page']) && !empty($_REQUEST['page']))?$_REQUEST['page']:1;
        $per_page = 8; //how much records you want to show
        $adjacents  = 4; //gap between pages after number of adjacents
        $offset = ($page - 1) * $per_page;
        //Count the total number of row in your table*/
        $count_query   = mysqli_query($con, "SELECT count(*) AS numrows FROM $sTable  $sWhere");
        $row= mysqli_fetch_array($count_query);
        $numrows = $row['numrows'];
        $total_pages = ceil($numrows/$per_page);
        $reload = './expences.php';
         $sql="SELECT * FROM  $sTable $sWhere LIMIT $offset,$per_page";
        $query = mysqli_query($con, $sql);
        if ($query === false) {
            die('Error SQL: ' . mysqli_errror($con));
        }
        //loop through fetched data
       
            
            ?>
<?php
    if($action == 'ajax'){
        // escaping, additionally removing everything that could be (html/javascript-) code
         $q = mysqli_real_escape_string($con,(strip_tags($_REQUEST['q'], ENT_QUOTES)));
          $aColumns = array('inmobiliaria_name', 'colonia', 'direccion', 'ubicacion', 'zona', 'inmueble_name', 'expediente');//Columnas de busqueda
         $sTable = "v_inventario_inmueble_completo ";
         $sWhere = "where inmobiliaria = 7";
        if ( $_GET['q'] != "" )
        {
            $sWhere = "WHERE (";
            for ( $i=0 ; $i<count($aColumns) ; $i++ )
            {
                $sWhere .= $aColumns[$i]." LIKE '%".$q."%' OR ";
            }
            $sWhere = substr_replace( $sWhere, "", -3 );
            $sWhere .= ')';
        }
        $sWhere.=" order by id desc";
         include 'pagination.php'; //include pagination file
        //pagination variables
        $page = (isset($_REQUEST['page']) && !empty($_REQUEST['page']))?$_REQUEST['page']:1;
        $per_page = 8; //how much records you want to show
        $adjacents  = 4; //gap between pages after number of adjacents
        $offset = ($page - 1) * $per_page;
        //Count the total number of row in your table*/
        $count_query   = mysqli_query($con, "SELECT count(*) AS numrows FROM $sTable  $sWhere");
        $row= mysqli_fetch_array($count_query);
        $numrows = $row['numrows'];
        $total_pages = ceil($numrows/$per_page);
        $reload = './expences.php';
         $sql="SELECT * FROM  $sTable $sWhere LIMIT $offset,$per_page";
        $query = mysqli_query($con, $sql);
        if ($query === false) {
            die('Error SQL: ' . mysqli_errror($con));
        }
        //loop through fetched data
       
            
            ?>
Recuerda que si ya le asignaste un valor a tu variable y no quieres perder el valor, debes concatenar utilizando .=
Origen Enlace
<?php
    if($action == 'ajax'){
        // escaping, additionally removing everything that could be (html/javascript-) code
         $q = mysqli_real_escape_string($con,(strip_tags($_REQUEST['q'], ENT_QUOTES)));
          $aColumns = array('inmobiliaria_name', 'colonia', 'direccion', 'ubicacion', 'zona', 'inmueble_name', 'expediente');//Columnas de busqueda
         $sTable = "v_inventario_inmueble_completo ";
         $sWhere = "where inmobiliaria = 7";
        if ( $_GET['q'] != "" )
        {
            $sWhere .= "WHERE" AND (";
            for ( $i=0 ; $i<count($aColumns) ; $i++ )
            {
                $sWhere .= $aColumns[$i]." LIKE '%".$q."%' OR ";
            }
            $sWhere = substr_replace( $sWhere, "", -3 );
            $sWhere .= ')';
        }
        $sWhere.=" order by id desc";
         include 'pagination.php'; //include pagination file
        //pagination variables
        $page = (isset($_REQUEST['page']) && !empty($_REQUEST['page']))?$_REQUEST['page']:1;
        $per_page = 8; //how much records you want to show
        $adjacents  = 4; //gap between pages after number of adjacents
        $offset = ($page - 1) * $per_page;
        //Count the total number of row in your table*/
        $count_query   = mysqli_query($con, "SELECT count(*) AS numrows FROM $sTable  $sWhere");
        $row= mysqli_fetch_array($count_query);
        $numrows = $row['numrows'];
        $total_pages = ceil($numrows/$per_page);
        $reload = './expences.php';
         $sql="SELECT * FROM  $sTable $sWhere LIMIT $offset,$per_page";
        $query = mysqli_query($con, $sql);
        if ($query === false) {
            die('Error SQL: ' . mysqli_errror($con));
        }
        //loop through fetched data
       
            
            ?>
<?php
    if($action == 'ajax'){
        // escaping, additionally removing everything that could be (html/javascript-) code
         $q = mysqli_real_escape_string($con,(strip_tags($_REQUEST['q'], ENT_QUOTES)));
          $aColumns = array('inmobiliaria_name', 'colonia', 'direccion', 'ubicacion', 'zona', 'inmueble_name', 'expediente');//Columnas de busqueda
         $sTable = "v_inventario_inmueble_completo ";
         $sWhere = "where inmobiliaria = 7";
        if ( $_GET['q'] != "" )
        {
            $sWhere = "WHERE (";
            for ( $i=0 ; $i<count($aColumns) ; $i++ )
            {
                $sWhere .= $aColumns[$i]." LIKE '%".$q."%' OR ";
            }
            $sWhere = substr_replace( $sWhere, "", -3 );
            $sWhere .= ')';
        }
        $sWhere.=" order by id desc";
         include 'pagination.php'; //include pagination file
        //pagination variables
        $page = (isset($_REQUEST['page']) && !empty($_REQUEST['page']))?$_REQUEST['page']:1;
        $per_page = 8; //how much records you want to show
        $adjacents  = 4; //gap between pages after number of adjacents
        $offset = ($page - 1) * $per_page;
        //Count the total number of row in your table*/
        $count_query   = mysqli_query($con, "SELECT count(*) AS numrows FROM $sTable  $sWhere");
        $row= mysqli_fetch_array($count_query);
        $numrows = $row['numrows'];
        $total_pages = ceil($numrows/$per_page);
        $reload = './expences.php';
         $sql="SELECT * FROM  $sTable $sWhere LIMIT $offset,$per_page";
        $query = mysqli_query($con, $sql);
        if ($query === false) {
            die('Error SQL: ' . mysqli_errror($con));
        }
        //loop through fetched data
       
            
            ?>
<?php
    if($action == 'ajax'){
        // escaping, additionally removing everything that could be (html/javascript-) code
         $q = mysqli_real_escape_string($con,(strip_tags($_REQUEST['q'], ENT_QUOTES)));
          $aColumns = array('inmobiliaria_name', 'colonia', 'direccion', 'ubicacion', 'zona', 'inmueble_name', 'expediente');//Columnas de busqueda
         $sTable = "v_inventario_inmueble_completo ";
         $sWhere = "where inmobiliaria = 7";
        if ( $_GET['q'] != "" )
        {
            $sWhere .= " AND (";
            for ( $i=0 ; $i<count($aColumns) ; $i++ )
            {
                $sWhere .= $aColumns[$i]." LIKE '%".$q."%' OR ";
            }
            $sWhere = substr_replace( $sWhere, "", -3 );
            $sWhere .= ')';
        }
        $sWhere.=" order by id desc";
         include 'pagination.php'; //include pagination file
        //pagination variables
        $page = (isset($_REQUEST['page']) && !empty($_REQUEST['page']))?$_REQUEST['page']:1;
        $per_page = 8; //how much records you want to show
        $adjacents  = 4; //gap between pages after number of adjacents
        $offset = ($page - 1) * $per_page;
        //Count the total number of row in your table*/
        $count_query   = mysqli_query($con, "SELECT count(*) AS numrows FROM $sTable  $sWhere");
        $row= mysqli_fetch_array($count_query);
        $numrows = $row['numrows'];
        $total_pages = ceil($numrows/$per_page);
        $reload = './expences.php';
         $sql="SELECT * FROM  $sTable $sWhere LIMIT $offset,$per_page";
        $query = mysqli_query($con, $sql);
        if ($query === false) {
            die('Error SQL: ' . mysqli_errror($con));
        }
        //loop through fetched data
       
            
            ?>
Fragmento de código solo debe usarse para código ejecutable
Origen Enlace
Triby
  • 25.2k
  • 3
  • 18
  • 36
Loading
etiquetas editadas; título editado
Enlace
Carlos
  • 421
  • 3
  • 17
Loading
Origen Enlace
Carlos
  • 421
  • 3
  • 17
Loading