Top Game Tips - Expekt bonuses - Find jobs - Italian Property - Debt Consolidation

PDA

View Full Version : Display by date


izlik
Oct 1st 2007, 3:57 pm
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 2nd 2007, 7:27 am
noone that can help ? :(

vonvhen
Oct 2nd 2007, 7:41 am
you can add the 'order by date' and then 'limit 10' to it

SELECT * FROM games WHERE id > 0 ORDER BY date LIMIT 10

izlik
Oct 2nd 2007, 7:59 am
thanks! :) now just, how would i be able to list the in a manner like bellow?

1: a
2: b
3: c

vonvhen
Oct 2nd 2007, 8:04 am
You can do a 'FOR LOOP' on your results.

e.g.
<?for ($i=0;$i<$resultsCount;$i++){
$num = $i+1;
echo $num.":".$results[$i];
<?}?>

izlik
Oct 2nd 2007, 8:18 am
ah! thank you very much vonvhen! :)

vonvhen
Oct 2nd 2007, 8:21 am
no problem...

you can append the "<br />" to the echo for the line break.