Tuesday, December 15, 2009

Navigation Using Mysql Query in php

If u want to navigate record without passing id array or other value sting following code will help u to move forward and backword on basis of present display id.

$selPre="select id from table where id<$imgId  and status='Yes' order by id Desc";
$preRs=mysql_query($selPre,$dbc)or die('error in previous id : '.mysql_error());
 <a title="Previous" href="Selffilename.php?Id=<?php echo $preId["id"];?>" class="no-underline">
<span style="color: rgb(105, 105, 105); font-weight: bold;">PREVIOUS</span>
<span class="paginate-first">&lt;&lt;</span>
<div align="right" style="width:50%; float:left">
$selNxt="select id from table where id>$Id and status='Yes' order by id ASC";
$NxtRs=mysql_query($selNxt,$dbc)or die('error in previous id : '.mysql_error());
<a title="Last Page" href="Selffilename.php?Id=<?php echo $nxtId["id"];?>" class="no-underline">
<span class="paginate-last">&gt;&gt;</span>
<span style="color: rgb(105, 105, 105); font-weight: bold;">NEXT</span>

No comments:

Post a Comment