Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Location
    Chelmsford, Essex
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Custom news script/feed assistance?

    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 Code:
    <?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");
    ?>

  • #2
    New to the CF scene
    Join Date
    Dec 2006
    Location
    Chelmsford, Essex
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 Code:
    <?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 > -
    {
        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");
    ?>
    MXR156
    Visit my site.
    Noobs Online


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •