Comunity,
After 1 month of hart work, I just have bumped into a simple problem I dont know to resolve. I just need to set a variable and be able to use its value in other pages. For example if $variable1 = "sing" I would need to use that value in other pages ( of course $variable1 change depending of a form ).
My problem is that I only know to use variable values from one page to an other using $_POST or $_GET , and only form the first page to a second one, if I need this value in a third page, I lost it, so I need to know how to set a variable to use in other pages or how can I do to keep the value introduced in a form in more than a second page?.
Target: resolve the paginate problem in a search form. When the page show registers not coming form a previous form, pagination work perfectly, is when I .
I get the first result page correctly, with the right number of pages, but when you click the second or subsequent pages, the query doesnt run.
Here the code:
$nombre_campo = strip_tags(trim($_POST['nombre_campo']));
$edad_campo1 = strip_tags(trim($_POST['edad_campo1']));
$edad_campo2 = strip_tags(trim($_POST['edad_campo2']));
$pais_campo = $_POST['pais_campo'];
$ciudad_campo = strip_tags(trim($_POST['ciudad_campo']));
$sexo_campo = $_POST['sexo_campo'];
$peso_campo1 = $_POST['peso_campo1'];
.......
/* ############ */
CONNECTION
/* ############ */
/inicializo el criterio y recibo cualquier cadena que se desee buscar
$criterio = "";
if ($_GET["criterio"]!=""){
$txt_criterio = strip_tags(trim($_GET["criterio"]));
$criterio = " where ( nombre like '%".$txt_criterio."%' OR anuncio like '%".$txt_criterio."%' OR edad like '%".$txt_criterio."%' OR aficcion like '%".$txt_criterio."%'
OR detesta like '%".$txt_criterio."%' OR peso like '%".$txt_criterio."%')";
}
//Limito la busqueda
$TAMANO_PAGINA = 4;
//examino la página a mostrar y el inicio del registro a mostrar
$pagina = $_GET["pagina"];
if (!$pagina) {
$inicio = 0;
$pagina = 1;
}
else {
$inicio = ($pagina - 1) * $TAMANO_PAGINA;
}
if ($orden_campo = '1')
{
$sql = "SELECT ..... THE QUERY
/* ############ */
SHOW OF DATA
/* ############ */
f ($total_paginas > 1)
{
for ($i=1;$i<=$total_paginas;$i++)
{
if ($pagina == $i)
{
// si muestro el índice de la página actual, no coloco enlace
echo $pagina . " ";
}
else
{
//si el índice no corresponde con la página mostrada actualmente, coloco el enlace para ir a esa página
echo "<a href='rdo_busqueda.php?pagina=" . $i . "&criterio=" . $txt_criterio . "'>" . $i . "</a> ";
}
}
}
--------------------------------------------------------------------------------
The first page show the first registers correctly, and the number of total pages.
It is here when return to href='rdo_busqueda.php and the variables
$nombre_campo, $edad_campo1 , ... has no valu, as there is nothing coming from any form.
Sorry to my long explanation, I have tried to describe my problem the best way.
I would thanks if anybody could help me.