Previous back and next row id hyperlinks from Mysql PHP

Description

Ho to get next and back content record post in Mysql PHP, Previous back and next row id hyperlinks from Mysql PHP content with SEO, Getting and display the next and the previous record in MySQL Php.How to fetch content in mysql database with row id input box and hyperlinks.Previous back and next row from mysql using php

 

$id=$_GET['id'];

$id = $currentid;

$prevquery= "SELECT * FROM inventory WHERE id < $currentid ORDER BY id DESC LIMIT 1"; 

$prevresult = mysql_query($prevquery);

 

$nextquery= "SELECT * FROM inventory WHERE id > $currentid ORDER BY id ASC LIMIT 1"; 

$nextresult = mysql_query($nextquery);

 

<a href="http://www.url.com/crud/edit.php?id=<?php echo $prevresult; ?> ">Previous</a>

 

<a href="http://www.url.com/crud/edit.php?id=<?php echo $nextresult; ?> ">Next</a>

 

$nextquery= "SELECT * FROM inventory WHERE id > $currentid ORDER BY id ASC LIMIT 1"; 

$nextresult = mysql_query($nextquery);

if(mysql_num_rows($nextresult) > 0)

{

    $nextrow = mysql_fetch_row($nextresult);

    $nextid  = $nextrow['id'];

}

 

 

2nd methor onclick input type submit

 

<?php

/* Put mysql connection code here */

 

 

if (isset($_POST['id'])) {

    $tmp = array_keys($_POST['id']);

    $curid = intval($tmp[0]);

 

    // Select contents from the selected id

    $sql = "SELECT field1,field2,field3 FROM table WHERE id={$curid}";

    $result = mysql_query($sql);

    if (mysql_num_rows($result)>0) {

        $info = mysql_fetch_assoc($result);

    } else {

        die('Not found');

    }

 

    // Next id

    $sql = "SELECT id FROM table WHERE id>{$curid} LIMIT 1";

    $result = mysql_query($sql);

    if (mysql_num_rows($result)>0) {

        $nextid = mysql_result($result,0);

    }

 

    // Prev id

    $sql = "SELECT id FROM table WHERE id<{$curid} LIMIT 1";

    $result = mysql_query($sql);

    if (mysql_num_rows($result)>0) {

        $previd = mysql_result($result,0);

    }

} else {

    // No form has been submitted so use the lowest id and grab its info

    $sql = "SELECT field1,field2,field3 FROM table WHERE id > 0 LIMIT 1";

    $result = mysql_query($sql);

    if (mysql_num_rows($result)>0) {

        $info = mysql_fetch_assoc($result);

    }

}

 

if (isset($info)) {

    $content = '<pre>'.print_r($info,true).'</pre>';

} else {

    $content =  'Nothing in the db :(';

}

?>

<html>

<head>

<title>Next prev</title>

</head>

<body>

<h3>Info</h3>

<?php echo $content; ?>

<form method="post">

<?php if (isset($previd)) { ?>

<input type="submit" name="id[<?php echo $previd?>]" value="prev">

<?php } ?>

<?php if (isset($nextid)) { ?>

<input type="submit" name="id[<?php echo $nextid?>]" value="next">

<?php } ?>

</form>

</body>

</html>

 

not run the program 

 

 

 

<?php

include("connect.php");

 

$query=("SELECT `uid` FROM `lagina` . `users`");

$select=mysql_query($query);

$row=mysql_fetch_array($select);

$id=$row[uid];

 

 

if (isset($_POST['next'])) {

$query_1=("SELECT `uid` FROM `lagina` . `users` WHERE `uid` > $id");

$select_1=mysql_query($query_1);

$row_1=mysql_fetch_array($select_1);

$id_1=$row_1[uid];

 

}

 

?>

<html>

<form action="test.php" method="POST">

<input type="submit" name="prev" value="pre">

<input type="submit" name="next" value="next">

<input type="hidden" name="pro" value="1">

 

</form>

</html>