Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8522893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:15:23+00:00 2026-06-11T07:15:23+00:00

I receive for example 26 results after a query using php. I want to

  • 0

I receive for example 26 results after a query using php. I want to paginate those results, showing 5 per-page.

The problem is that in order to send the query I have to do an http post using the information of a form I fill.

The first 5 results show, but then the next page will give me errors about some variables not being defined — the variables that came from the original request.

Here is the form code:

<form name="formulario" action="resultados.php" method="POST"> 
            <input name="titulo" type="text" id="cajatitulo" class="cuadrobusqueda" placeholder="T&iacute;tulo de la publicaci&oacute;n (Ej: La fotos&iacute;ntesis y sus procesos)"> 
            <input name="anio" type="text" id="cajaanio" class="cuadrobusqueda" placeholder="A&ntilde;o">
            <br><br>
            <input name="autor" type="text" id="cajaautor" class="cuadrobusqueda" placeholder="Apellido del autor (Ej: Rojas, J; Rojas; J)"> 
            <input name="issn" type="text" id="cajaissn" class="cuadrobusqueda" placeholder="ISSN">
            <br><br>
            <input type="radio" name="tipo_busqueda" value="1" checked>
            <span onmouseover="title='Busca todos los parámetros seleccionados en un artículo.'">B&Uacute;SQUEDA EXACTA</span>
            <input type="radio" name="tipo_busqueda" value="2"> 
            <span onmouseover="title='Busca cualquiera de los parámetros seleccionados en un artículo.'">B&Uacute;SQUEDA FLEXIBLE</span>            
            </br></br>
            <input type="submit" name="boton" id="botonenviar" value="Procesar">
</form>

That data is sent to the results.php, where the post is extracted and paginated with this code:

extract($_POST);

include("conectar.php");

$conexion= conectarse();

$consulta="";
$tipo="";

if($tipo_busqueda=="1")
    $tipo="AND";
else
    $tipo="OR";

if($titulo && $consulta == "" )
    $consulta=" web.titulo_paper_web LIKE '%$titulo%'";

$consulta = '
    SELECT 
        * 
    FROM 
        acw_papers_web web 
    WHERE 
        '.$consulta.'
    ORDER BY 
        web.probabilidad DESC';
$resultado= mysql_query($consulta, $conexion);

if (!isset($paginanum)) 
    $paginanum = 1; 
$mostrar_resultados = 5;            
$filas = mysql_num_rows($resultado);    
$ultima = ceil($filas/$mostrar_resultados);         
if ($paginanum < 1)
    $paginanum = 1; 
elseif ($paginanum > $ultima)
    $paginanum = $ultima;

$max = 'LIMIT '.(paginanum - 1) * $mostrar_resultados .',' .$mostrar_resultados; 
$consulta = $consulta . " $max";
$resultado= mysql_query($consulta, $conexion);

Below that code I generate the data that links me to the next page:

 if ($paginanum != 1) {
    echo "<a class='navegar' href='{$_SERVER['PHP_SELF']}?paginanum=1'> <b><<</b> Primera</a> ";
    echo " ";
    $anterior = $paginanum-1;
    echo " <a class='navegar' href='{$_SERVER['PHP_SELF']}?paginanum=$anterior'> <b><</b> Anterior</a> ";
} 
if ($paginanum != $ultima) {
    $siguiente = $paginanum+1;
    echo " <a class='navegar' href='{$_SERVER['PHP_SELF']}?paginanum=$siguiente'>Siguiente <b>></b> </a> ";
    echo " <span>  </span>";
    echo " <a class='navegar' href='{$_SERVER['PHP_SELF']}?paginanum=$ultima'>&Uacute;ltima <b>>></b> </a> ";
}
echo "</br>";

That code works, but subsequent pages do not work. I tried passing that data on the url:

&titulo=$titulo&issn=$issn&autor=$autor&anio=

but it did not work

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:15:24+00:00Added an answer on June 11, 2026 at 7:15 am

    Submit your form via get then create a querystring based on $_GET:

    $querystring = "";
    foreach ($_GET as $key => $val) {
        if ($key != 'paginanum') {
            $querystring .= ($querystring == "" ? "" : "&") . "$key=$val";
        }
    }
    

    Then append the querystring to your link URL.

    It’s not very secure, but it works.

    Update:

    Sam Dufel just reminded me of PHP’s http_build_query() function, which is better:

    $vals = $_GET;
    unset($vals['paginanum']);
    $querystring = http_build_query($vals);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We receive (#4) Application request limit reached error when a page is showing the
For invoke search android example, every time query search result is received by onCreate().
I want to plot email from and to in world. For example, I received
My problem is simple in nature- query a database, and write output to a
I was practising with an example that I was creating like the one below
I am building a jcr query and receive data from repository. Here is my
I'm using Stroustrup's swan book. I have run into a problem getting output from
I'm using mongoose in a script that is not meant to run continuously, and
Basic question for PHP experts out there. I'm writing a page where the variable
I have a code where I receive YUV channels and I'm drawing them using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.