| TonySweeps |
12-07-2012 03:27 AM |
Stuck on an IF statement
Background: I have a database of sweepstakes. I am trying to get a "new" image to appear in the listing when the startdate is within 7 days of the current date.
I am not able to get it to appear. I annotated the new part below. Any ideas? I'm stuck on it.
Here is most of the code...
PHP Code:
$sql = "SELECT startdate,sponsor,url,prize,enddate,prizevalue,category,frequency,country,AB,BC,MB,NB,NL,NT,NS,NU,ONT,PE,QC,SK,YT FROM SweepDirectory WHERE category = 'Cash' and status = 'Y' and enddate > DATE_SUB(CURDATE(), INTERVAL 1 DAY) ORDER BY enddate ASC ";
$result = mysql_query($sql, $conn); $num= mysql_num_rows($result);
mysql_close();
$num;
if($num % 3 == 0) { echo 'image file'; }
$i=0; while ($i < $num) {
$startdate=mysql_result($result,$i,"startdate"); $sponsor=mysql_result($result,$i,"sponsor"); $category=mysql_result($result,$i,"category"); $prizevalue=mysql_result($result,$i,"prizevalue"); $prize=mysql_result($result,$i,"prize"); $url=mysql_result($result,$i,"url"); $enddate=mysql_result($result,$i,"enddate"); $frequency=mysql_result($result,$i,"frequency"); $country=mysql_result($result,$i,"country"); $AB=mysql_result($result,$i,"AB"); $BC=mysql_result($result,$i,"BC"); $MB=mysql_result($result,$i,"MB"); $NB=mysql_result($result,$i,"NB"); $NL=mysql_result($result,$i,"NL"); $NT=mysql_result($result,$i,"NT"); $NS=mysql_result($result,$i,"NS"); $NU=mysql_result($result,$i,"NU"); $NB=mysql_result($result,$i,"ONT"); $PE=mysql_result($result,$i,"PE"); $QC=mysql_result($result,$i,"QC"); $SK=mysql_result($result,$i,"SK"); $YT=mysql_result($result,$i,"YT");
//this is the part I am working on.
$startdate = 'DATE_SUB(now(), INTERVAL 7 DAY)';
if ( $startdate > 'DATE_SUB(now(), INTERVAL 7 DAY)' ) { echo "<img src='images/newii.gif' border='0'>"; } echo "";
echo " <font size=3><b>$sponsor</b></font><br /> <a href=\"$url\" target=\"_blank\">"; echo substr($prize, 0, 150); echo "</a><br /> <b>Prize Value:</b> \$$prizevalue <b>End Date: </b> $enddate <b>Frequency:</b> $frequency <br /> <b>Country:</b> $country <b>Province:</b> $AB $BC $MB $NB $NL $NT $NS $NU $ONT $PE $QC $SK $YT<br /> <a href=\"$url\" target=\"_blank\">"; echo substr($url, 0, 50); echo " </a> <hr><br>";
$i++; } ?>
|