Browsing results, a little preoblem.
Posted: Sat Mar 15, 2003 10:03 am
I have a database and I'm trying to show the results of a search grouped in the amount of five, and to go the next five or come back to the previous.
I'm using "LIMIT" in the query for doing this and I think I will arrange it, but I have a mysql_num_rows function there that is responsible to show the total amount of coincidences, and by this way, the variable returns the values asigned to LIMIT, not the total one.
<?php
$base="bla";
$tabla="DatosInmueble";
$conexion = mysql_connect(bla) or die(mysql_error());
mysql_select_db($base,$conexion) or die(mysql_error());
$clauses = array();
if (isset($_POST['envio1'] ) && $_POST['envio1'] != -1)
$clauses[] = 'Modo='.(int)$_POST['envio1'];
if (isset($_POST['envio2'] ) && $_POST['envio2'] != -1)
$clauses[] = 'Localidad='.(int)$_POST['envio2'];
if (isset($_POST['envio3'] ) && $_POST['envio3'] != -1)
$clauses[] = 'Tipo='.(int)$_POST['envio3'];
if (isset($_POST['envio4'] ) && $_POST['envio4'] != -1)
$clauses[] = 'Habitaciones='.(int)$_POST['envio4'];
if (isset($_POST['envio5'] ) && $_POST['envio5'] != -1)
$clauses[] = 'Precio<='.(int)$_POST['envio5'];
$query = "SELECT * FROM $tabla LIMIT 0,5";
if (count($clauses) > 0)
$query .= ' WHERE '.join('AND ', $clauses);
$pegar=mysql_query($query, $conexion) or die($query.' :'.mysql_error());
$coincidencias=mysql_num_rows($pegar);
?>
I'm using "LIMIT" in the query for doing this and I think I will arrange it, but I have a mysql_num_rows function there that is responsible to show the total amount of coincidences, and by this way, the variable returns the values asigned to LIMIT, not the total one.
<?php
$base="bla";
$tabla="DatosInmueble";
$conexion = mysql_connect(bla) or die(mysql_error());
mysql_select_db($base,$conexion) or die(mysql_error());
$clauses = array();
if (isset($_POST['envio1'] ) && $_POST['envio1'] != -1)
$clauses[] = 'Modo='.(int)$_POST['envio1'];
if (isset($_POST['envio2'] ) && $_POST['envio2'] != -1)
$clauses[] = 'Localidad='.(int)$_POST['envio2'];
if (isset($_POST['envio3'] ) && $_POST['envio3'] != -1)
$clauses[] = 'Tipo='.(int)$_POST['envio3'];
if (isset($_POST['envio4'] ) && $_POST['envio4'] != -1)
$clauses[] = 'Habitaciones='.(int)$_POST['envio4'];
if (isset($_POST['envio5'] ) && $_POST['envio5'] != -1)
$clauses[] = 'Precio<='.(int)$_POST['envio5'];
$query = "SELECT * FROM $tabla LIMIT 0,5";
if (count($clauses) > 0)
$query .= ' WHERE '.join('AND ', $clauses);
$pegar=mysql_query($query, $conexion) or die($query.' :'.mysql_error());
$coincidencias=mysql_num_rows($pegar);
?>