
07/09/2005, 04:33
|
| | Fecha de Ingreso: septiembre-2005
Mensajes: 1
Antigüedad: 19 años, 6 meses Puntos: 0 | |
problemas con paginacion y busqueda Buenos dias, tengo una duda en php y me gustaría que me echarais una mano. Arealizar una paginación con la sentencia SQL = select * from $tabla WHERE PropType LIKE '$PropType' ORDER BY PriceEuros LIMIT $inicial,$cantidad
me la hace bien, pero cuando a esa misma sentencia le pongo:
select * from $tabla WHERE PriceEuros Between '$Price_from' And '$Price_upto' And PropType LIKE '$PropType' And Bedrooms Between '$Bed_from' And '$Bed_upto' Or Reference LIKE '$Reference' ORDER BY PriceEuros para realizar unas busqueda avanzada la primera pagina me la muestra pero las siguientes me las deja en blanco. El código entero es:
<?
$Reference=$_POST['Reference'];
$Price_from=$_POST['Price_from'];
$Price_upto=$_POST['Price_upto'];
$PropType=$_POST['PropType'];
$Bed_from=$_POST['Bed_from'];
$Bed_upto=$_POST['Bed_upto'];
$pg=$_GET['pg'];
$query=$_GET['query'];
$db="inmo";
$tabla="Properties";
include("connectDB.php");
$link=Conectarse();
if (!isset($_GET['pg'])){
$pg = 0;
}
$cantidad = 1;
$inicial = $pg * $cantidad;
$query="select * from $tabla WHERE PropType LIKE '$PropType' ORDER BY PriceEuros LIMIT $inicial,$cantidad";
$result=mysql_query($query)
or die(mysql_error());
//calculamos las paginas a mostrar
$contar = "SELECT * FROM $tabla";
$contarok = mysql_db_query($db,$contar);
$total_records = mysql_num_rows($contarok);
$pages = intval($total_records / $cantidad);
if ($total_records < 1){
echo "Sorry, There is no result...";
// Cerramos la conexión a la base
$link=mysql_close($link);
}
else{
while ($row=mysql_fetch_object($result))
{
echo "
<table border=0 cellpadding=0 cellspacing=0 width=500 align=center>
<tr>
<td width=280 rowspan=8 class=text>
<p align=center><img src=/properties/$row->Reference(1).jpg width=100 height=100></td>
</tr>
<tr>
<td width=202 class=text>Ref: </td>
<td width=556 class=text>$row->Reference</td>
<td width=138 rowspan=7>
<a href=results_details.php?Reference=$row->Reference><img border=0 src=/images/more_info.png width=138 height=129 alt=+Info></a></td>
</tr>
<tr>
<td width=202 class=text>Prop Type:</td>
<td width=556 class=text>$row->PropType</td>
</tr>
<tr>
<td width=202 class=text>Price €: </td>
<td width=556 class=text>$row->PriceEuros</td>
</tr>
<tr>
<td width=202 class=text>Price £: </td>
<td width=556 class=text> </td>
</tr>
<tr>
<td width=202 class=text>Town:</td>
<td width=556 class=text>$row->Town</td>
</tr>
<tr>
<td width=202 class=text>Bedrooms: </td>
<td width=556 class=text>$row->Bedrooms</td>
</tr>
<tr>
<td width=202 class=text>Bathrooms: </td>
<td width=556 class=text>$row->Bathrooms</td>
</tr>
</table>";
}
echo "";
if ($pg <> 0)
{
$url = $pg - 1;
echo "<a href='results.php?pg=".$url."'>« Preview</a> ";
}
else {
echo " ";
}
for ($i = 0; $i<($pages + 1); $i++) {
if ($i == $pg AND $pg <> 0) {
echo " $i ";
}
elseif ($i == $pg AND $pg == 0) {
echo " ";
}
else {
echo "<a href='results.php?pg=".$i."'>".$i."</a> ";
}
}
if ($pg < $pages) {
$url = $pg + 1;
echo "<a href='results.php?pg=".$url."'>Next »</a>";
}
else {
echo " ";
}
echo "";
}
?>
Un saludo y gracias de antemano |