Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF within WHILE

Status
Not open for further replies.

Ravensleach

Programmer
Oct 19, 2004
45
PE
I'm trying to list an array and where the date field is less than 10 days ago, flag the record as "new".

Can anyone tell me why this isn't working?


Code:
<?
$query = "SELECT date, name FROM tbl_onepagers WHERE fktheme = $id OR fktheme2 = $id OR fktheme3 = $id OR fktheme4 = $id OR fktheme5 = $id OR fktheme6 = $id";
$result = mysql_query($query) or die(mysql_error());
$date = mysql_query($query[date]);
$currentdate = DATE("Y-m-d");

 
// print list
echo "<ol>";
while($row = mysql_fetch_array($result)){
echo "<li><a href='#'>"; 
if ($date >= $currentdate - 10) 
{
echo "<span class = 'new'>(New)</span> "; 
} 
echo $row['name'] . "</a></li>" ;
}
echo "</ol>";

?>

Thanks for your help!
 
Code:
if(strtotime($row['date']) > strtotime('-10 days')){

}

and delete these two lines
Code:
$date = mysql_query($query[date]);
$currentdate = DATE("Y-m-d");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top