Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Problem with paginate passing variables ($_Get)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
fontecu
Smarty Rookie


Joined: 10 Feb 2005
Posts: 5

PostPosted: Thu Feb 10, 2005 3:50 pm    Post subject: Problem with paginate passing variables ($_Get) Reply with quote

I need some body to help me or give me an example of setting url variables, because i pass the variables that I need, but the next variable value I lost in every iteration.

thanks

help me

Code:
<?php
   require('Smarty/Smarty.class.php');
   require('adodb/adodb.inc.php');
   require('Conecciones/Conección.php');
   require('Clases/EstudiantesBusq.php');
   require('Smarty/SmartyPaginate.class.php');
   
   
   //redireccionar a la página de autenticación si el usuario no esta registrado
   session_start();
   if (!isset($_SESSION['ssUsuario'])){
      header("location:autenticación.php");
   }
   
   $Estudiantes[] = '';
   $visible = false;
   
   $Nombre = '';
   $Apellidos = '';
   $CI = '';
   
   
   if (isset($_POST["btnBuscar"]) or isset($_GET["next"])){
      
      if (isset($_POST['txtNombre'])) {
         $Nombre = $_POST['txtNombre'];
      }
      else{
         $Nombre = '';
      }
      if (isset($_POST['txtApellidos'])) {
         $Apellidos = $_POST['txtApellidos'];
      }
      else{
         $Apellidos='';
      }
      
      if (isset($_POST['txtCI'])) {
         $CI = $_POST['txtCI'];
      }
      else{
         $CI='';
      }
      
      if (isset($_GET['Nombre'])) {
         $Nombre = $_GET['Nombre'];
      }
      
      
      if (isset($_GET['Apellidos'])) {
         $Apellidos = $_GET['Apellidos'];
      }
      
      
      if (isset($_GET['CI'])) {
         $CI = $_GET['CI'];
      }
      
      
      $queryInicial = "SELECT dbo.Estudiantes.CI, dbo.Estudiantes.Nombre, dbo.Estudiantes.Apellidos, dbo.Paises.País, dbo.Especialidades.Especialidad
                   FROM dbo.Documentación INNER JOIN dbo.Estudiantes ON dbo.Documentación.Código = dbo.Estudiantes.CodDocumentación INNER JOIN
                   dbo.Especialidades ON dbo.Estudiantes.CodEspecialidad = dbo.Especialidades.Codigo INNER JOIN dbo.Paises ON dbo.Estudiantes.CodPais = dbo.Paises.Codigo INNER JOIN
                   dbo.Razas ON dbo.Estudiantes.CodRaza = dbo.Razas.Codigo INNER JOIN dbo.Situacion ON dbo.Estudiantes.CodSituacion = dbo.Situacion.Codigo INNER JOIN
                   dbo.TipoEstudiante ON dbo.Estudiantes.CodTipoEstudiante = dbo.TipoEstudiante.Código";

      
      if (($Nombre == '') && ($Apellidos != '') && ($CI == '')){
         $query =  $queryInicial . " WHERE Apellidos LIKE '%' + '$Apellidos' + '%'";
         $variable = 'Apellidos='.$Apellidos;
      }
      
      if (($Nombre != '') && ($Apellidos == '') && ($CI == '')){
         $query = $queryInicial . " WHERE Nombre LIKE '%' + '$Nombre' + '%'";
         $variable = 'Nombre='.$Nombre;
      }
      
      if (($Nombre != '') && ($Apellidos != '') && ($CI == '')){
         $query = $queryInicial . " WHERE Apellidos LIKE '%' + '$Apellidos' + '%' AND Nombre LIKE '%' +'$Nombre' + '%'";
         $variable = 'Nombre='.$Nombre.'&Apellidos='.$Apellidos;
      }
      
      if (($Nombre == '') && ($Apellidos != '') && ($CI != '')){
         $query = $queryInicial . " WHERE Apellidos LIKE '%' + '$Apellidos' + '%' AND CI='$CI'";
         $variable = 'Apellidos='.$Apellidos.'&CI='.$CI;
      }
      
      if (($Nombre != '') && ($Apellidos == '') && ($CI != '')){
         $query = $queryInicial . " WHERE Nombre LIKE '%' + '$Nombre' + '%' AND CI='$CI'";
         $variable = 'Nombre='.$Nombre.'&CI='.$CI;
      }
      
      
      if (($Nombre != '') && ($Apellidos != '') && ($CI != '')){
         $query = $queryInicial . " WHERE Apellidos LIKE '%' + '$Apellidos' + '%' AND Nombre LIKE '%' +'$Nombre' + '%' AND CI='$CI'";
         $variable = 'Nombre='.$Nombre.'&Apellidos='.$Apellidos.'&CI='.$CI;      
      }
      
      if (($Nombre == '') && ($Apellidos == '') && ($CI != '')){
         $query = $queryInicial . " WHERE  CI='$CI'";
         $variable = 'CI='.$CI;       
      }
      
      
      if (($Nombre != '') or ($Apellidos != '') or ($CI != '')){
         
         $rsBuscarEst=$conn->Execute($query);
         
         while (!$rsBuscarEst->EOF){
            $Estudiantes[] = new EstudianteBusq($rsBuscarEst->fields['Nombre'],$rsBuscarEst->fields['Apellidos'],$rsBuscarEst->fields['País'],$rsBuscarEst->fields['Especialidad'],$rsBuscarEst->fields['CI']);         
            $rsBuscarEst->MoveNext();
         }
         if ($rsBuscarEst->RecordCount()<>0){
       
             $visible = true;
         }
      }
   }
   
   
   $BuscarSmarty = new Smarty();
   
   
    SmartyPaginate::connect();
 
   
   SmartyPaginate::setLimit(3);
   $_data = $Estudiantes;
   SmartyPaginate::setTotal(count($_data));
   if (($Nombre<>'') or ($Apellidos<>'') or ($CI<>'')){
      
      SmartyPaginate::setUrlVar($variable);
   }
   $Arreglo = array_slice($_data, SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
   
    $BuscarSmarty->assign('results', $Arreglo);
   
    SmartyPaginate::assign($BuscarSmarty);
 
      
   $BuscarSmarty->assign('Estudiantes',$Estudiantes);
   $BuscarSmarty->assign('visible',$visible);
   $BuscarSmarty->display('BuscarEst.tpl');
   
   ?>
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Feb 10, 2005 5:09 pm    Post subject: Reply with quote

What does your template look like? Are you getting the vars appended to the next/prev links in there?

Also, array_slice() was used in the README example because it was using a simple array, not a database result. You should probably not need array_slice() with database result sets.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP