Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/05/2005, 11:20
raml
 
Fecha de Ingreso: abril-2005
Mensajes: 50
Antigüedad: 19 años
Puntos: 0
Como paso tantas variables en la URL

Los valores definidos en los campos del formulario son muchos. ¿Cómo los añado todos a la URL del paginador? ¿Cómo los convierto en una sola variable?

Hay una opción en la configuración del script que pongo a continuación (ver Script II) que te permite definir esta variable para que la pases en la cadena, se llama $extra_var. El asunto es que no sé que poner

A continuación pongo la info de los scripts...


ESTRUCTURA DE LA BUSQUEDA

Código PHP:
<?php 

//CALENDARIO: Permite que la fecha utilizada para buscar la base de datos se siga viendo en el calendario de esta página. Ejemplo: si buscaste 26 Febrero 2005 en subpagina.php entonces una vez que los resultados se muestren en subpagina6busqueda.php, el calendario de esta página seguira mostrando 26 Febrero 2005. Lo mismo si sólo buscaste por mes y/o  año.
    
    
$diaid $_POST['diaid'];
    
$mesid $_POST['mesid'];
    
$anoid $_POST['anoid'];

    
    
$select1 ' SELECT diaid, mesid, anoid';
    
$from1   ' FROM dias, meses, anos';
    
$where1  ' WHERE 1=1';
    
    
$diaid $_POST['diaid'];
    if (
$diaid != '') { // An author is selected
      
$where1 .= " AND diaid = '$diaid'";
    }
    
    
$mes $_POST['mesid'];
    if (
$mes != '') { // An author is selected
      
$where1 .= " AND mesid = '$mesid'";
    }
    
    
$ano $_POST['anoid'];
    if (
$ano != '') { // An author is selected
      
$where1 .= " AND anoid = '$anoid'";
    }
    
    
$query = ($select1 $from1 $where1);
    
$result mysql_query($query) or die ("Error in query: $query. " mysql_error());
    
$row mysql_fetch_object($result);

// BUSQUEDA: Este script permite obtener la lista de noticias (por título) en la base de datos, a partir de la búsqueda por dia, mes y/o año realizada en subpagina.php

    
$select '    SELECT id, titulo';
    
$from   ' FROM p_documentos';
    
$where  ' WHERE 1=1';
    
$order  ' ORDER BY id_ano desc, id_mes desc, id_dia desc';

    
    
$dia $_POST['diaid'];
    if (
$dia != '') { // An author is selected
      
$where .= " AND id_dia='$dia'";
    }
    
    
$mes $_POST['mesid'];
    if (
$mes != '') { // An author is selected
      
$where .= " AND id_mes='$mes'";
    }
    
    
$ano $_POST['anoid'];
    if (
$ano != '') { // An author is selected
      
$where .= " AND id_ano='$ano'";
    }

?>
PAGINACIÓN SCRIPT 1

Código PHP:
<?php 
// Pagination script --- index.php
/* This script automates teh creation of navigation links for the datas extracted from 
    the database. It is preety simple and uses php and mysql to do this. Check out
    mpageni.com and pkronline.com where this scripts is in action everywhere.
    I created and i think i should share it. 
    Author: Manoj Pageni; http://mpageni.com; [email protected]
    Lisence: GPL.
    Copyright of mpageni.com.
*/
// Pagination script --- index.php

// file to be included
include 'config.php'
include 
'style.inc';

//Check if the page number is defined else set it to one. Standard Procedure. :)
if(!isset($_GET['page'])){
    
$page 1;}
    else {
$page $_GET['page']; 

//Calclate the offsets
$from = (($page $max_results) - $max_results); 
// Creat the query to be performed and then perform it.
        
$sql mysql_query("$query_list LIMIT $from, $max_results");

// pre_result output
echo $pre_result;

while(
$row mysql_fetch_array($sql)){ // loop through the result of the page.
    
$bgcolor =  ($bgcolor == $bgcolor1) ? $bgcolor2$bgcolor1//for altering background color.
        
include("template.inc");


//post_result output
echo $post_result;

// Calculate the total number of results.
$total_results mysql_result(mysql_query("SELECT COUNT($fields) as Num FROM $table"),0); 

// Calculate the total number of pages. ceil() is used to round the page number to the higher integer. 
$total_pages ceil($total_results $max_results); 



// The real stuff. Creats the Navigation Menu
//Set font style for navigation area
echo "<div class=\"text\"><center>$nav_title<br>"
// Create the Previous link.
if($page 1){ 
    
$prev = ($page 1); 
    echo 
"<a class=\"nav\" href=\"".$_SERVER['PHP_SELF']."?$httpvar=$prev\">$pre_style</a>&nbsp;"

//Creat the navigation page numbers.
for($i 1$i <= $total_pages$i++){ 
    if((
$page) == $i){ // make sure the link is not given to the page being viewed
        
echo "$i&nbsp;"
        } else { 
            echo 
"<a class=\"nav\" href=\"".$_SERVER['PHP_SELF']."?$httpvar=$i\">$i</a>&nbsp;"
    } 

// Create the next link.
if($page $total_pages){ 
    
$next = ($page 1); 
    echo 
"<a class=\"nav\" href=\"".$_SERVER['PHP_SELF']."?$httpvar=$next\">$next_style</a>"

echo 
"</center></div>";
echo 
$post_nav;

?>
PAGINACIÓN SCRIPT 2 (opciones de configuración)

Código PHP:
<?
// Pagination script --- config.php
// Configuration file. Contains functions and variables required by the script.
/* This script automates teh creation of navigation links for the datas extracted from 
    the database. It is preety simple and uses php and mysql to do this. Check out
    mpageni.com and pkronline.com where this scripts is in action everywhere.
    I created and i think i should share it. 
    Author: Manoj Pageni; http://mpageni.com; [email protected]
    Lisence: GPL.
    Copyright of mpageni.com.
*/

//General Configuration Variables
$max_results 4// Define the number of results per page 
$next_style '->'// The look for the next button
$pre_style '<-';//The look for the previous button
$extra_var ='';    //end with & if used. this is the variable you will pass if required.

//WARNING do not modify the $httpvar.
$httpvar $extra_var.'page'
$bgcolor1='#eeeeee';    //one of the background colors
$bgcolor2='#ffffff';    //the other background color;
$bgcolor $bgcolor1;    //the first background color to be used
$pre_result='';
$post_result='';
$post_nav='';
$nav_title='Páginas';

// Style.inc definitions
$nav_text_size'8pt';
$nav_link_color'green';
$nav_text_color='navy';
$nav_text_family='Verdana';
$nav_text_style='bold'//bold, italics
$nav_link_bg='#eeeeee';
//Database configuration; // please change the variables below as required// a must
$user="root";
$pass="xxxxxxxx";
$host="localhost";
$db="xxxxxxxx";
$table="xxxxxxx";
$fields=('*');  // please separate by commas if you use multiple fields

//Database connection. Do not modify below this.
$conn mysql_connect($host,$user,$pass);
mysql_select_db($db,$conn);
// mysql query to be performed
$query_list = ($select $from $where $order);
?>