C
CSharp
C++
Java
Visual Basic
HTML - CSS
Android
Asp
Asp.Net
Php
Python
JavaScript
SQL
XML
Assembly
Algorithms
Arrays
Code Snippets
Cookies
Databases
Date Time
E-Mail
Graphics
HTML and PHP
Look and Feel
MySQL
Strings
More...
Php > Site Navigation sample source codes
Php Code > Navigate through records
Navigate through records <?php // Variables for navigating between previous and next record id $previd = $id-1; $nextid = $id+1; // Your database connection code $dbcnx = mysql_connect('localhost:', 'mysql','yourpass') or die("Error Occurred"); mysql_selectdb("YourDB"); $query = "SELECT * FROM yourtable WHERE id='$id'"; $result = mysql_query($query, $dbcnx); $row = mysql_fetch_array($result); // Checking and displaying data If (($id > 0) && ($id <= sizeof($row))) { echo $row['your array']; echo "<a href=\"page.php?id=$previd\">Previous</a> <a href=\"page.php?id=$nextid\">Next</a>"; } else { if ($id < 1) { echo "Beginning of Record Set"." "; echo "<a href=\"page.php?id=$nextid\">Next</a>"; } else { echo "End of Record Set"." "; echo "<a href=\"page.php?id=$previd\">Previous</a>"; } } ?>
Privacy Policy
|
Contact
|
Advertising
|
Link to Us
|
Directory