mxr156
12-24-2006, 01:30 PM
I have written a news script and i want there too be a link/button at the bottom of the page where you can click and it will go to the next 10 articles in the database, i have wrote the below script and dont know how i would set it out? At the moment the links are permenently showing and i want them to change to dead links if there is nothing left in the database or it gets to 0. Any help will be apreciated.
Thanks
Andy
<?php
include("includes/header.inc");
include("includes/style.inc");
if ( $_GET[limit] == "" )
{
$newslimit1 = "0";
}
else
{
$newslimit1 = $_GET[limit];
}
$newslimit2 = $newslimit1 + 10;
echo"<span class='Lheading'>Welcome</span><br /><br />
Welcome to Noobs Online.co.uk<br /><br />
<span class='Mheading'>Latest News</span><br /><br />";
$news_sql = "SELECT * FROM noobsonline_news ORDER BY news_ID DESC LIMIT $newslimit1, $newslimit2";
$news_result = mysql_query($news_sql);
while ($news_row = mysql_fetch_array($news_result))
{
extract($news_row);
echo"<span class='XSheading'>$news_title</span><br />
$news_text<br />
<b>By:</b> $news_author <b>on</b> $news_date <b>at</b> $news_time<br /><br />";
if($counter == 0)
{
echo"";
}
$counter++;
}
$bottomlimit = $newslimit1 - 10 ;
$toplimit = $newslimit2 ;
echo"<a href='index.php?limit=$bottomlimit'><< Last 10 <<</a> <b>::</b> <a href='index.php?limit=$toplimit'>>> Next 10 >></a>";
include("includes/footer.inc");
?>
Thanks
Andy
<?php
include("includes/header.inc");
include("includes/style.inc");
if ( $_GET[limit] == "" )
{
$newslimit1 = "0";
}
else
{
$newslimit1 = $_GET[limit];
}
$newslimit2 = $newslimit1 + 10;
echo"<span class='Lheading'>Welcome</span><br /><br />
Welcome to Noobs Online.co.uk<br /><br />
<span class='Mheading'>Latest News</span><br /><br />";
$news_sql = "SELECT * FROM noobsonline_news ORDER BY news_ID DESC LIMIT $newslimit1, $newslimit2";
$news_result = mysql_query($news_sql);
while ($news_row = mysql_fetch_array($news_result))
{
extract($news_row);
echo"<span class='XSheading'>$news_title</span><br />
$news_text<br />
<b>By:</b> $news_author <b>on</b> $news_date <b>at</b> $news_time<br /><br />";
if($counter == 0)
{
echo"";
}
$counter++;
}
$bottomlimit = $newslimit1 - 10 ;
$toplimit = $newslimit2 ;
echo"<a href='index.php?limit=$bottomlimit'><< Last 10 <<</a> <b>::</b> <a href='index.php?limit=$toplimit'>>> Next 10 >></a>";
include("includes/footer.inc");
?>