...

View Full Version : Custom news script/feed assistance?



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'>&lt;&lt; Last 10 &lt;&lt;</a> <b>::</b> <a href='index.php?limit=$toplimit'>&gt;&gt; Next 10 &gt;&gt;</a>";

include("includes/footer.inc");
?>

mxr156
12-24-2006, 05:54 PM
ok i asked on another support forum and got the code below, but it still isnt helping because i dont know what to put for the no more posts tests to make sure the link doesnt show if there is no more posts and doesn go below 0 so it pulls up an error?? anyone got any ideas??


<?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"&nbsp;&nbsp;";

if ( $bottomlimit > -9 )
{
echo"<a href='index.php?limit=$bottomlimit'>&lt;&lt; Last 10 &lt;&lt;</a>";
}
else
{
echo "&lt;&lt; Last 10 &lt;&lt;";
}
echo " <b>::</b> ";
if (SOME TEST THAT THERE ARE MORE ITEMS AFTER THIS PAGE)
{
echo"<a href='index.php?limit=$toplimit'>&gt;&gt; Next 10 &gt;&gt;</a>";
}
else
{
echo "&gt;&gt; Next 10 &gt;&gt;";
}
include("includes/footer.inc");
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum