Ir para conteúdo
Fórum Script Brasil

fabiocassiano

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre fabiocassiano

fabiocassiano's Achievements

0

Reputação

  1. Estou buscando um grid via <script>, o grid já esta pronto com as consultas etc... porem tenho que colocar no select da consulta uma $variavel, where id = "$id". como o grid esta vindo de um script não estou conseguindo levar essa condição, já tentei com $_GET['id'] = o GET vai ate atrapalhar, uma vez que a pagina que chama o GRID já esta com GET[id] filtrando. session_start() = quando coloco na pagina que esta o GRID não funciona! alguém consegue me ajudar? <?php session_start(); $id = $_SESSION['id_cliente']; //include connection file include_once("./conn.php"); // initilize all variable $params = $totalRecords = $data = array(); $sqlTot = $sqlRec = $where = ""; $params = $_REQUEST; $limit = $params["rowCount"]; if (isset($params["current"])) { $page = $params["current"]; } else { $page=1; }; $start_from = ($page-1) * $limit; // check search value exist if( !empty($params['searchPhrase']) ) { $where .=" WHERE "; $where .=" ( nome LIKE '".$params['searchPhrase']."%' "; $where .=" OR cpf LIKE '".$params['searchPhrase']."%' "; $where .=" OR uf LIKE '".$params['searchPhrase']."%' )"; } if( !empty($params['sort']) ) { $where .=" ORDER By ".key($params['sort']) .' '.current($params['sort'])." "; } // getting total number records without any search $sql = "SELECT * FROM `cliente` where id_cliente = "$id" "; $sqlTot .= $sql; $sqlRec .= $sql; //concatenate search sql if value exist if(isset($where) && $where != '') { $sqlTot .= $where; $sqlRec .= $where; } if ($limit!=-1) $sqlRec .= "LIMIT $start_from, $limit"; $queryTot = mysqli_query($conn, $sqlTot) or die("database error:". mysqli_error($conn)); $totalRecords = mysqli_num_rows($queryTot); $queryRecords = mysqli_query($conn, $sqlRec) or die("error to fetch employees data"); //iterate on results row and create new index array of data while( $row = mysqli_fetch_assoc($queryRecords) ) { $data[] = $row; //echo "<pre>";print_R($data);die; } $json_data = array( "current" => intval( $params['current'] ), "rowCount" => 10, "total" => intval( $totalRecords ), "rows" => $data // total data array ); echo json_encode($json_data); // send data as json format ?>
×
×
  • Criar Novo...