In my table view, I have a list of articles. These are sorted 1-100. When I click the link (gpage=viewArticle&id=1) to open to the article view I want to add a button or link at the bottom of the article page that will advance to gpage=viewArticle&id=2 when clicked. From that page, click to advance to gpage=viewArticle&id=3, and so on. How is this done? Anyone have an example to follow?
Forums
Advance to next record
Read the database, getting the first ID higher than the ID you're on.
At the bottom of the article detail page (gpage=viewArticle&id=1) I have a button. From there I select the submit page to be (viewArticle). Is this where I begin with reading the DB and getting the first id higher than the id I'm on in the Where Conditions box? I guess this is the part that simply eludes me.
I have the code here that works, I just cannot figure out how to get it to run inside of CF7. Here's what I am using to read the DB outside of CF7 (for testing). I'd like to have the buttons at the bottom of my viewArticle that would advance to the next record based on id < or >. This code works, just can't figure out how to get it working inside CF7
<?php
require_once("config.php");
$id = $_GET['id'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Previous and Next</title>
</head>
<body>
<?php
$result = mysqli_query($mysqli, "SELECT * FROM #_idtable WHERE id=$id");
if($row = mysqli_fetch_array($result))
{
$name = $row['name'];
$lot = $row['lot'];
}
?>
<h1> <?php echo $name;?></h1>
<p> <?php echo $lot;?></p>
<div class="group">
<?php
// Next button
$next = mysqli_query($mysqli, "SELECT * FROM #_idtable WHERE id>$id order by id ASC");
if($row = mysqli_fetch_array($next))
{
echo '<a href="show.php?id='.$row['id'].'"><button type="button">Next</button></a>';
}
// Previous button
$previous= mysqli_query($mysqli, "SELECT * FROM #_idtable WHERE id<$id order by id DESC");
if($row = mysqli_fetch_array($previous))
{
echo '<a href="show.php?id='.$row['id'].'"><button type="button">Previous</button></a>';
}
?>
</div>
You need to login to be able to post a reply.