Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2012, 03:27 AM   PM User | #1
TonySweeps
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
TonySweeps is an unknown quantity at this point
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);
$nummysql_num_rows($result);

mysql_close();


 
$num;

  if(
$num == 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($prize0150); echo "</a><br /> 
<b>Prize Value:</b> \$$prizevalue &nbsp;&nbsp;&nbsp;&nbsp; <b>End Date: </b> $enddate &nbsp;&nbsp;&nbsp;&nbsp; <b>Frequency:</b> $frequency <br />
<b>Country:</b> $country&nbsp;&nbsp;&nbsp;&nbsp; <b>Province:</b> $AB $BC $MB $NB $NL $NT $NS $NU $ONT $PE $QC $SK $YT<br />
<a href=\"$url\" target=\"_blank\">"
; echo substr($url050); echo " </a>
<hr><br>"
;

$i++;
}
 
?> 

Last edited by Inigoesdr; 12-08-2012 at 03:22 AM..
TonySweeps is offline   Reply With Quote
Old 12-07-2012, 09:52 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,689
Thanks: 158
Thanked 2,184 Times in 2,171 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
mysql_close();
You may omit that line from your code since mysql will automatically close the connection when the execution completes Or you need to move that line to the very end of your PHP code.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 12-08-2012, 12:59 AM   PM User | #3
>ssp-cdr<
Regular Coder

 
Join Date: May 2007
Posts: 100
Thanks: 16
Thanked 11 Times in 11 Posts
>ssp-cdr< is an unknown quantity at this point
it seems odd that $startdate is a string containing what looks like code

$startdate = 'DATE_SUB(now(), INTERVAL 7 DAY)';
__________________
The CodingForums Funny Images thread ** Now with 20+ pages!! ** - http://www.codingforums.com/showthread.php?t=245405
>ssp-cdr< is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:28 AM.


Advertisement
Log in to turn off these ads.