Sorry to all,
I didn't completely write the query and mistakenly submitted the thread. Here is edited query.
Please go thorugh the following code. This kind of query might have put before, but look into this also.
<?php
$fname_v = ltrim($HTTP_POST_VARS['fname_v']);
$mname_v = ltrim($HTTP_POST_VARS['mname_v']);
$lname_v = ltrim($HTTP_POST_VARS['lname_v']);
/ call function to build query sting with count /
$query_count = prep_qry_count($fname_v, $mname_v, $lname_v);
$limit=12;
$Prev = "< Previous";
$Next = "Next >";
$numresults=mysql_query($query_count);
$res = mysql_fetch_array($numresults);
$numrows=$res[0]; / count obtained from given query /
?>
<table>
<tr> <td class="showmsg"> <?php echo $numrows; ?> Records found </td></tr>
</table>
<?php
if($numrows > 0)
{
$pages=intval($numrows/$limit);
/ no.of pages required to print result according to limit which is set/
// initially set current page =1
if (empty($HTTP_POST_VARS['curr_page'])) { $curr_page = 1; }
$prev_page = $curr_page - 1;
$next_page = $curr_page + 1;
if (empty($HTTP_POST_VARS['offset']))
/ first time offset contains null value. set it to zero /
{ $offset = 0; }
/ run the query with offset and limt values. to display limited records per page /
/ first call function to build the query string /
$query = prep_query($fname_v, $mname_v, $lname_v);
// echo $query;
$sql = "$query LIMIT $offset,$limit ";
$result = mysql_query($sql) or die("SELECT Failed");
/ start code to display PREV and NEXT links at the top of the page/
if ($numrows%$limit)
{
$pages++;
}
?>
<TABLE BORDER="0" width="100%" CELLSPACING="0" CELLPADDING="2" ALIGN="CENTER" >
<TR>
<TD ALIGN="CENTER" width="95%" class="nextprev">
<?php
for ($i=1;$i<=$pages;$i++)
{
$newoffset=$limit*($i-1);
if ($i != $curr_page)
{
print "<a href=\"$PHP_SELF?limit=$limit&&offset=$newoffset&&curr_page=$i&&fname_v=$fname_v&&mname_v=$mname_v&&lname_v=$lname_v\">$i</a>   ";
}
else {
echo $i;
}
}
if ($offset>=1)
/ if offset>1 means no.of records are greater than limit. hence Prev link is to used /
{
$prevoffset=$offset-$limit;
print " <a href=\"$PHP_SELF?limit=$limit&&offset=$prevoffset&&curr_page=$prev_page&&fname_v=$fname_v&&mname_v=$mname_v&&lname_v=$lname_v\">$Prev</a>   ";
}
if ($numrows>($offset+$limit)) /* if no.of records are greater than offset+limit next page is required. hence use next link here */
{
$nextoffset=$offset+$limit;
print " <a href=\"$PHP_SELF?limit=$limit&&offset=$nextoffset&&curr_page=$next_page&&fname_v=$fname_v&&mname_v=$mname_v&&lname_v=$lname_v\">$Next</a>   ";
}
?>
</TD>
<td width="5%" class="nextprev"><a href="javascript:history.back()">back </a></td>
</TR>
</TABLE>
With the above code, I want to display the records fetched on multiple pages. For the first page, records are shown properly, but by clicking second page onward, the records are not refreshed.
What changes are required? Is there any alternate way of handling this sort of coding?
Thanks in advance.