#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    Hi, I've got a news script which posts al the news, starting with the newest one. My question is how to post only the 10 most recent newsitems on the main page, and all the others on the archives page ? The problem is that i can only work with the posting date to do this, cause there's no ID# in the database. So i need to know how i can manipulate the lines to look at the date before posting and act accordingly to date:

    <?
    $result=mysql($database,"select * from news order by datum desc");

    while ($row = mysql_fetch_array($result)) {

    $datum = date("d-m-Y", $row[datum]);

    print '<table width="550" border="0" cellspacing="0" cellpadding="0" align="center"><tr>';
    print '<td width="37"><img src="images/title_links.jpg" width="37" height="50"></td>';
    print '<td width="390" background="images/title_midden.jpg">';
    printf ("<font size=-1><a name="%s"> %s</a></font>",$row[title],$row[title]);
    print '<td width="86" background="images/title_midden.jpg">';
    printf ("<font size=-2> $datum</font></td>",$row[title]);
    print '<td width="37"><img src="images/title_rechts.jpg"></td><tr><br>';
    print '<table width="450" border="0" cellspacing="0" cellpadding="0" align="center"><tr>';
    printf ("<br><font size=-1> %s </a></font><br><br>",$row[itemtext]);
    printf ("<font size=-2><p>By %s <p></a></font><br><br>",$row[postername]);

    }
    ?>

    Can you pls help me ?

    thx in advance.
    Raven

    ------------------
    Life is a bitch, and then u die
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    well, it's quite easy..

    2 solutions:

    A. use LIMIT in mysql query
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    //select most recent 10 messages
    $result=mysql($database,"SELECT * FROM news ORDER BY datum DESC LIMIT 0,10");
    //select 1000 archive messages
    $result=mysql($database,"SELECT * FROM news ORDER BY datum DESC LIMIT 10,1000");
    [/code]

    B. implement in php code do display 1st 10
    or after 10 for archive pages

    ------------------
    Greetings lewi
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    Thx a lot Lewi, that's just what I needed.

    I just have one more question, how can I let the viewers only see the desired newsitem in the archive ?
    a sort of searchengine by date. So user has to chose date (intervals of one week) en then gets to see the news from that week

    Is this also that easy ?



    ------------------
    Life is a bitch, and then u die

Similar Threads

  1. database date selection problem
    By kidsleep in forum MySQL Help
    Replies: 0
    Last Post: January 31st, 2004, 11:50 AM
  2. subquery for date not working
    By xsarpedonx in forum MySQL Help
    Replies: 4
    Last Post: December 19th, 2003, 12:58 AM
  3. date manipulation (first tuesday of the month, etc)
    By madeonmoon in forum Java Help
    Replies: 1
    Last Post: December 8th, 2003, 10:22 AM
  4. News posting system
    By FirEwAteR in forum PHP Development
    Replies: 4
    Last Post: November 6th, 2003, 10:21 AM
  5. date addition problem
    By strange1 in forum PHP Development
    Replies: 3
    Last Post: October 6th, 2003, 05:01 PM

IMN logo majestic logo threadwatch logo seochat tools logo