izlik
Oct 13th 2007, 2:39 pm
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>
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>