#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    34
    Rep Power
    2

    Question PHP Query Assistant


    Hi Everyone,

    I'm new to this code, however, am trying to learn.

    Recently had a website built and there was some PHP used within it - some of it I understand, some of it I don't.

    This is a news page article (darlingtontowntwinning.co.uk/testing.php).
    As you can see the news just keeps appearing on the right hand side.
    What I am looking to do, is to limit the amount of news that appears on the page (say until the 1/1/12) and then for all articles to display (either on the same or a different page) when "See More News" is clicked from the bottom of the list.

    I've been told that I'll need a WHERE query added into the code, I just can't work out where.
    If you guys could help, that'd be great!

    Code:
    <div id="right" class="news">
    <h3>Archive</h3>
    <? $news=$session->getNews("","","",1);?>
    <? while($article=mysql_fetch_array($news)){?>
    <? 
    $date = $article['thedate'];
    $year = date('Y', $date);
    $month = date('F', $date);
    ?>
    <h4><?=$month." - ".$year;?></h4>
    <nav class="small">
    <? $innernews=$session->getNews("",$month,$year);?>
    <? while($innerarticle=mysql_fetch_array($innernews)){?>
    <a href="/news/<?=$innerarticle['ftitle']?>" <? if($title==$innerarticle['ftitle']){?> class="active"<? }?>><?=$innerarticle['title']?></a>
    <? }?>
    </nav>
    <? }?>
    </div>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,403
    Rep Power
    594
    1) STOP! If you are just learning DO NOT use the depreciated MySQL extensions. Use PDO.
    2) Please enclose your code in [ PHP ] tags. See the sticky at the top of the forum list and ManiacDan's New User Guide.
    3) This is not really a PHP question but rather a MySQL question.
    4) One of the reasons you are struggling is that you are not looking in the right place. You do not show your query string. Post the class definitions for the database especially the class containing the getNews method and the query string.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo