Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default [PHP]Make XX First

    Ok, say I have some news articles that are displayed using mySQL and PHP.

    When I add a new article, the newer one goes at the bottom. How do I make it so the newer one displays at the top.

  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    PHP Code:
    ORDER BY `lolDESC 

  3. #3
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    what do I replace with 'lol'?

  4. #4
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    And if you want it to display only 5 then:
    PHP Code:
    SELECT  FROM  `newsORDER  BY `id`  DESC LIMIT 0 
    Last edited by Moh; 14-02-2008 at 11:43 PM.

  5. #5
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    Gosh I'm a nub.

    Where would I add that in this:
    PHP Code:
    <?php
    include "config.php";

    $sql "SELECT * FROM news";
    $check mysql_query("SELECT authour, title, news_content, date FROM news") or die("There is no news at the moment.");

    while (
    $display mysql_fetch_array($check)) {

        
    $news_content $display['news_content'];
        
    $title $display['title'];
        
    $authour $display['authour'];
        
    $date $display['date'];
        echo 
    "<h2>$title - <span>by $authour</span></h2>
    <p>
    $news_content<br />
    <strong><i>Posted on: 
    $date</i></strong></p><br />
    <br />
    "
    ;
        }
    ?>
    NVM: Got it. Thank you Simon and Jack.
    Last edited by loserWILL; 14-02-2008 at 11:48 PM.

  6. #6
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    Egh, the "DESC LIMIT 0 , 5" is causing me problems:

    The firts news title is fine, but the second news article's title is shifted to the right When I removed that desc limit it's fine, but it doesn't order the news how I want it to.

  7. #7
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    [quote=loserWILL;4447420]Gosh I'm a nub.

    $sql = "SELECT * FROM news";

    What the hell do you keep putting that in there for it serves no purpose.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  8. #8
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    I'll remove that.

    Does anybody know the answer to the question I posted above?

  9. #9
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    PHP Code:
    SELECT FROM `newsORDER BY `news`.`idASC LIMIT 0 
    The `id` is what its ordering by.

  10. #10
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    That doesn't order it properly, or at leats how I want it to order.

Page 1 of 3 123 LastLast

Posting Permissions

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