Hello, i need a little help with the code bellow, im trying to make it select the latests added stuff into the databaste by date from the collumn "added" and sort it in a 1:A 2:B 3:C manner but it wont work, do anyone know why? <?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 date LIMIT 10"); while($row = mysql_fetch_array($result)) { echo $row['added']; echo "<br />"; } mysql_close($con); ?> <?for ($i=0;$i<$resultsCount;$i++){ $num = $i+1; echo $num.":".$results[$i]; <?}?> PHP:
In your ODER BY clause, use ORDER BY `added` instead of ORDER BY date Also, I assume that the "for" loop at the bottom of your code was pasted by mistake? it references variables you haven't set, and it contains a syntax error: <?}?> should just be }?>
thanks you! and yes that was a misstake. Question however, some of the games in the database has the date 00:00:0000 set to them due to a database problem that occoured a while ago, but it shown the ones with the 00:000:0000 first in the list and not th ones added this week or yesterday. why? also, if there is more then 10 games added at the same latests date, how can i make the list randomize between those that was added ? and one last thing, how could i make each listing have a link to for example http://mysite.com/[id] and id is supposed to be the ID number of the line where it picked the date from from thanks in advance.
for hte link issue, i think it's someting like http://mydomain.com/<?=$_GET['id']?>/ right? but where in the code above should i place it, that's what confuse me.