Hi,
I'm trying to create previous and next links for my news page. I have searched this forum and found serveral scripts that will do the job but I couldnt figure out how to modify them for my needs.
I managed to get on of the scripts to display the num of pages and the correct links but I was then unable to figure out how to display my content with the script.
This is what i have now but it doesnt work:
<?php
include("db.php");
$artist ="".$_GET['$artist']."";
if(!isset($start)) $start = 0;
$limit = "1";
$query = "SELECT * FROM `news` WHERE `artist` = '$artist' LIMIT " . $start . ",".$limit."";
//do database connection
$result = mysql_query($query); //you should do error checking
//display data // is this in the right place?
echo '<b>'.stripslashes($result['title']).'</b> '.stripslashes($result['newstext']).'';
//this code was wrong, I did not have the second query. Thanks to Plaggy Pig.
// need another query to get the total amount of rows in our table
$query = "SELECT count(*) as count FROM news";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - $limit) .
"&artist=".stripslashes($artist)."\">Previous</a><BR>\n";
if($numrows > ($start + 10))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + $limit) .
"&artist=".stripslashes($artist)."\">Next</a><BR>\n";
?>
Any help would be greatly apreciated.
Thanks