Previous and Next Record


#1

HI!

I need some kind of script that shows Prev and Next records on a data base… I already have one that works… but only if the records are followed.

I have in the same table several kinds of data and the detail page should only show all the records of the same kind. this is my code:

[php]

<?php mysql_connect ("localhost", "***", "***") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("*****"); $result =mysql_query( "SELECT * FROM T_DECORACAO WHERE (ID='$ID') AND (TIPO='igrejas')"); $imgurl = "*****/"; while($resposta = @mysql_fetch_array($result)) { $IDDET=$resposta['ID']; $TIPO=$resposta['TIPO']; $FOTOG=$imgurl.$resposta['FOTOG']; $NEXT= $IDDET+1; $PREV= $IDDET-1; ?>
          <img src="<?php echo $FOTOG;?>" ></div></td>
        </tr>
      <tr>
        <td height="20"><div align="center"><span class="style5"><?php 

if ($IDDET==1) {
echo “Seguinte >” ;
} else {
echo “< Anterior | Seguinte >” ;
}

?>
[/php]

in this specific case the IDS are " 1,2,4,5,6,7,8,79,80"

can you help me please???

thankyou

Mod Edit: Added PHP tags for readability.


#2

Could you provide a more clear description of your problem? Such as any error messages you’re getting, or what you’ve tried so far?

The reason I’m asking is because this looks kinda like a ‘fix my script’ request, which is not allowed here :slight_smile: