...

View Full Version : newbie needa help in php paging



odin_vani
01-24-2007, 07:28 AM
hello friends,

thanks in advance for your help. i'm and newbee for php mysql. so i need your help on paging in php page.

my html search page is like this. search.html

<form action="search_result.php" method="post" name="qsearch" id="qsearch">
<table width="98%" border="0" align="right" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">Search Property for</font></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">
<input name="preference" type="radio" value="Sale" checked>
Sale
<input type="radio" name="preference" value="Rent">
Rent
<input type="radio" name="preference" value="All">
Both </font></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">Property
Type</font></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">
<select name="ptype" id="select2">
<option value="All" selected>Select One</option>
<option value="Agricultural Land">Agricultural Land</option>
<option value="Apartments">Apartments</option>
<option value="Commercial Showrooms">Commercial Showrooms</option>
<option value="Farm House">Farm House</option>
<option value="Residential House">Residential House</option>
<option value="Residential Site">Residential Site</option>
</select>
</font></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">Location</font>
</td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">
<select name="location" id="select4">
<option value="All" selected>Select One</option>
<option value="Alandurai">Alandurai</option>
<option value="Athikadvu">Athikadvu</option>
<option value="Bharathiar University">Bharathiar University</option>
<option value="Chettipalayam">Chettipalayam</option>
<option value="Coimbatore Aerodrome">Coimbatore Aerodrome</option>
<option value="Coimbatore Central">Coimbatore Central</option>
<option value="Sidco">Sidco</option>
<option value="Chinniampalayam">Chinniampalayam</option>
<option value="Chokkampudur">Chokkampudur</option>
</select>
</font></td>
</tr>
<tr>
<td width="33%" align="left"><font size="2" face="Arial, Helvetica, sans-serif">
<input type="submit" name="Submit" value="Go">
</font> </td>
</tr>
</table>
</form>


and my result page goes like this search_result.php

<?
include 'include/config.php';
$preferen=$_POST['preference'];
$locat=$_POST['location'];
$ptype=$_POST['ptype'];
?>
<form method="">
<table width="100%" border="1" cellpadding="4" cellspacing="0" bordercolor="#ABC5A0">
<tr bgcolor="#CBDBC4">
<td width="5%"><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">ID</font></strong></div></td>
<td width="22%"><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">Location</font></strong></div></td>
<td width="23%"><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">Property Type</font></strong></div></td>
<td width="15%"><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">Price</font></strong></div></td>
<td width="15%"><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">Property For</font></strong></div></td>
<td width="10%"><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">Details</font></strong></div></td>
</tr>
<?php

$sql = "SELECT * FROM datas_prop ORDER BY date desc";
$rs=mysql_query($sql);
$rscount=mysql_num_rows($rs);

if($rscount!=0)
{
if ($preferen=="All" && $locat=="All" && $ptype=="All")
{
while($rsdata = mysql_fetch_object($rs))
{
?>
<tr>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->id;?></font></div></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->location;?></font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->ptype;?></font></td>
<td><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->price;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->preference;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="details.php?id=<?=$rsdata->id;?>">Details</a></font></div></td>
</tr>
<?
}
}
else if($preferen=="All" && $ptype=="All")
{
while($rsdata = mysql_fetch_object($rs))
{
if($rsdata->location==$locat)
{
?>
<tr>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->id;?></font></div></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->location;?></font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->ptype;?></font></td>
<td><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->price;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->preference;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="details.php?id=<?=$rsdata->id;?>">Details</a></font></div></td>
</tr>
<?
}
}
}
else if($locat=="All" && $ptype=="All")
{
while($rsdata = mysql_fetch_object($rs))
{
if($rsdata->preference==$preferen)
{
?>
<tr>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->id;?></font></div></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->location;?></font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->ptype;?></font></td>
<td><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->price;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->preference;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="details.php?id=<?=$rsdata->id;?>">Details</a></font></div></td>
</tr>
<?
}
}
}
else if($preferen=="All" && $locat=="All")
{
while($rsdata = mysql_fetch_object($rs))
{
if($rsdata->ptype==$ptype)
{
?>
<tr>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->id;?></font></div></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->location;?></font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->ptype;?></font></td>
<td><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->price;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->preference;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="details.php?id=<?=$rsdata->id;?>">Details</a></font></div></td>
</tr>
<?
}
}
}
else if($locat=="All")
{
while($rsdata = mysql_fetch_object($rs))
{
if($rsdata->preference==$preferen && $rsdata->ptype==$ptype)
{
?>
<tr>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->id;?></font></div></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->location;?></font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->ptype;?></font></td>
<td><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->price;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->preference;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="details.php?id=<?=$rsdata->id;?>">Details</a></font></div></td>
</tr>
<?
}
}
}
else if($ptype=="All")
{
while($rsdata = mysql_fetch_object($rs))
{
if($rsdata->preference==$preferen && $rsdata->location==$locat)
{
?>
<tr>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->id;?></font></div></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->location;?></font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->ptype;?></font></td>
<td><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->price;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->preference;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="details.php?id=<?=$rsdata->id;?>">Details</a></font></div></td>
</tr>

<?
}
}
}
else if($preferen=="All")
{
while($rsdata = mysql_fetch_object($rs))
{
if($rsdata->location==$locat && $rsdata->ptype==$ptype)
{
?>
<tr>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->id;?></font></div></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->location;?></font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->ptype;?></font></td>
<td><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->price;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->preference;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="details.php?id=<?=$rsdata->id;?>">Details</a></font></div></td>
</tr>
<?
}
}
}
else
{
while($rsdata = mysql_fetch_object($rs))
{
if($rsdata->preference==$preferen && $rsdata->ptype==$ptype && $rsdata->location==$locat)
{
?>
<tr>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->id;?></font></div></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->location;?></font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->ptype;?></font></td>
<td><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->price;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?=$rsdata->preference;?></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><a href="details.php?id=<?=$rsdata->id;?>">Details</a></font></div></td>
</tr>
<?
}
}
}
}
else
{
?>
<tr><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">
No property available in this Location at present. Please Check later.</font></div></tr>
<?
}
?>
</table>
</form>

this works for me, but i need to add paging into this. i tried a lot of things, the first page works and the rest of the page doesn't work. also if there is no property available the message "No property available in this Location at present. Please Check later" doesn't display.

kindly help me.

Fumigator
01-24-2007, 07:24 PM
Use Firepage's paging script (http://www.firepages.com.au), it'll do all the work for you. It is easy to set up (you will need to carefully follow the set-up instructions), and it works great.

p.s. in the future be sure to wrap your code in [ PHP ] tags [ /PHP ] when pasting code into a message.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum