Display by date

Discussion in 'PHP' started by izlik, Oct 1, 2007.

  1. #1
    Hello.

    in one of my Mysql databases called 'games' i have a collumn called "added".

    now i wonder how i can make my php page/code display 10 of the newest added games by date, and if it's more then 10 added at let's say (09:02:2007) it could just pick 10 at random to display from that date. the date is in "Month:Date:Year" as also shown in the example above.

    if possible, how could they be displayed in a top 10 manners as bellow?

    1: name1
    2: name2
    3: etc

    i hope someone can help me. thanks in advance.
     
    izlik, Oct 1, 2007 IP
  2. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #2
    noone that can help ? :(
     
    izlik, Oct 2, 2007 IP
  3. vonvhen

    vonvhen Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you can add the 'order by date' and then 'limit 10' to it

    SELECT * FROM games WHERE id > 0 ORDER BY date LIMIT 10
     
    vonvhen, Oct 2, 2007 IP
  4. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #4
    thanks! :) now just, how would i be able to list the in a manner like bellow?

    1: a
    2: b
    3: c
     
    izlik, Oct 2, 2007 IP
  5. vonvhen

    vonvhen Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can do a 'FOR LOOP' on your results.

    e.g.
    <?for ($i=0;$i<$resultsCount;$i++){
    $num = $i+1;
    echo $num.":".$results[$i];
    <?}?>
     
    vonvhen, Oct 2, 2007 IP
  6. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #6
    ah! thank you very much vonvhen! :)
     
    izlik, Oct 2, 2007 IP
  7. vonvhen

    vonvhen Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    no problem...

    you can append the "<br />" to the echo for the line break.
     
    vonvhen, Oct 2, 2007 IP