MrCreeky Posted September 25, 2008 Share Posted September 25, 2008 Hi, I'm wanting to show a link if today's date is 14 days before an event. Here is what I came up with but none of it works. <?php if date("D,M,Y"); < ($row_rs1_events['myedate']); echo (<a href="regs/<?php echo $row_rs1_events['regs']; ?>" target="_blank">Download Regs</a>); ?> or <?php $countdown = "14"; if date("dS F Y"); <($countdown) + ($row_rs1_events['myedate']); print (<a href="regs/<?php echo $row_rs1_events['regs']; ?>" target="_blank">Download Regs</a>); ?> Could someone give me a push? Link to comment https://forums.phpfreaks.com/topic/125801-a-little-help/ Share on other sites More sharing options...
discomatt Posted September 25, 2008 Share Posted September 25, 2008 Are you getting the data from mysql? SELECT `events` FROM `table` WHERE `date` BETWEEN NOW() AND DATE_ADD( NOW(), INTERVAL 14 DAY ) That will select all rows where `date` is between today and 14 days from now. Link to comment https://forums.phpfreaks.com/topic/125801-a-little-help/#findComment-650561 Share on other sites More sharing options...
Prismatic Posted September 25, 2008 Share Posted September 25, 2008 clean code! <?php $countdown = "14"; if(date("dS F Y") < ($countdown) + ($row_rs1_events['myedate'])) { print ("<a href=\"regs/{$row_rs1_events['regs']}\" target=\"_blank\">Download Regs</a>"); } ?> Link to comment https://forums.phpfreaks.com/topic/125801-a-little-help/#findComment-650568 Share on other sites More sharing options...
discomatt Posted September 25, 2008 Share Posted September 25, 2008 clean code! <?php $countdown = "14"; if(date("dS F Y") < ($countdown) + ($row_rs1_events['myedate'])) { print ("<a href=\"regs/{$row_rs1_events['regs']}\" target=\"_blank\">Download Regs</a>"); } ?> Well formed, but won't work. You need to use unix timestamps if you want to do it with PHP alone. Link to comment https://forums.phpfreaks.com/topic/125801-a-little-help/#findComment-650570 Share on other sites More sharing options...
MrCreeky Posted September 25, 2008 Author Share Posted September 25, 2008 Hi, Thanks for getting back to me. Yes, all the data is coming up from a mySQL database. Tried this, don't get any errors but the page still shows all the links from the year and not just the ones with only 14 days to go before the event. <?php $unixtime = time(); $countdown = "14"; if(date("dS F Y",$unixtime) < ($countdown) + ($row_rs1_events['myedate'])) { print ("<a href=\"regs/{$row_rs1_events['regs']}\" target=\"_blank\">Download Regs</a>"); } ?> Link to comment https://forums.phpfreaks.com/topic/125801-a-little-help/#findComment-650723 Share on other sites More sharing options...
discomatt Posted September 26, 2008 Share Posted September 26, 2008 Did you try my solution? Link to comment https://forums.phpfreaks.com/topic/125801-a-little-help/#findComment-650903 Share on other sites More sharing options...
redarrow Posted September 26, 2008 Share Posted September 26, 2008 you need this that all as advised........... remember anythink mysql can do use it.......... SELECT `events` FROM `table` WHERE `date` BETWEEN NOW() AND DATE_ADD( NOW(), INTERVAL 14 DAY ) [code] [/code] Link to comment https://forums.phpfreaks.com/topic/125801-a-little-help/#findComment-650910 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.