Hello. This code bellow is supposed to pick out 10 items from my database and list them wich it do. im trying to make it list them depending on date and need some help as i cant get it to work. right now it list 10 items with a date from last month and i have no clue why, can someone help me make this code able to list the 10 that has the latest date in the database? my date format in the database is like t his "2007-10-10 13:59:21" and the collumn where the date resides is in "added" in the table "games" <table class="main2" id="table12" border="1" width="102"> <tr> <td class="entry" bgcolor="#FFFF00" bordercolorlight="#FF6600" bordercolordark="#FF6600"> 10 Newest games<div class='new games'> <?php $con = mysql_connect("localhost","login,"password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $result = mysql_query("SELECT * FROM games WHERE id > 0 ORDER BY `name` LIMIT 10"); while($row = mysql_fetch_array($result)) { echo '<a href="http://mypage.com/index.php?params=game/'.$row['id'].'">'.$row['name'].'</a>'; echo "<br />"; } mysql_close($con); ?><?for ($i=0;$i<$resultsCount;$i++){ $num = $i+1; echo $num.":".$results[$i]; } ?></div></td> </tr> </table> PHP:
Apparently not digipren it dont show the games that i added just a few day's ago, it just picks the one at top of the database and shows them insteed wich are way old. someone said it can be becuase the collun "added" is not a "valid date field" if this is true, how can i solve that ?
what is the type of added ? String, datetime ? and what is <?for ($i=0;$i<$resultsCount;$i++){ $num = $i+1; echo $num.":".$results[$i]; } ?> supposed to do ?
that last bit of code ignore that please, it was pasted by misstake, i have removed that. and "added" is a normal collumn in my "games" table. it's supposed to be a datetime
"ORDER BY added DESC" should work... if you want, dump a few lines of your table and I'll try the query on my side.