I am creating a database for a game, i want it to look like this one [url]http://dominionagencies.com/warrants/warrantlist.php[/url] where admin enter the number of days, for example person A is aos for 2 days so after 2 days this should not be displayed anymore. I would use a form to enter number of days. But my problem is the php coding, so can anyone help me?
I used this code for something similar as what you are asking for. In my case I want to show a "NEW" image for stuff loaded in less that 7 days. This is the code:
[CODE] <?php // What day is today: $todayis = strtotime(date('Y-m-d'));
// I define the limite date getting the created date on the DB and adding 7 days $limitedate= strtotime($row_rsproductos['date_created'], mktime(0,0,0,0,7,0));
// Then I compare the today's date with the limit day and if today is lower than the limit date, then I'll display what I want if($todayis <= $limitedate) { ?> <div class="newitemlabel"><img src="images/newlabel.png" /></div> <?php } ?> [/CODE]
I hope it helps somehow! I'm not an advance developer, this works fine for me. I'm sure there must be a better way and surely some of the gurus around here can help us all to get this better, but for a non-advance developer, I think this is simple enough!
I used this code for something similar as what you are asking for. In my case I want to show a "NEW" image for stuff loaded in less that 7 days. This is the code:
[CODE] <?php // What day is today: $todayis = strtotime(date('Y-m-d'));
// I define the limite date getting the created date on the DB and adding 7 days $limitedate= strtotime($row_rsproductos['date_created'], mktime(0,0,0,0,7,0));
// Then I compare the today's date with the limit day and if today is lower than the limit date, then I'll display what I want if($todayis <= $limitedate) { ?> <div class="newitemlabel"><img src="images/newlabel.png" /></div> <?php } ?> [/CODE]
I hope it helps somehow! I'm not an advance developer, this works fine for me. I'm sure there must be a better way and surely some of the gurus around here can help us all to get this better, but for a non-advance developer, I think this is simple enough!
@eval_BadCode_Sep 27.2011 — #You could try the jqueryUI's datepicker (javascript). But it's an incredible amount of code for just picking a date... I would avoid using it unless you're already very invested in jqueryUI (I use it all over the place, even wrote a library in PHP for it). ?
If you're interested the PHP code looks like this:
[code=php] <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Date Picker</title> <link type="text/css" href="css/dot-luv/jquery-ui-1.8.13.custom.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.13.custom.min.js"></script> </head> <!-- <?php #errors are in the comments, also, the browser can begin #processing the jquery scripts while the server is processing the PHP function __autoload($class_name) { require_once('./classes/' . $class_name . '.php'); } //normally this is also auto prepended... just making sure you know how the classes are loaded
I can share the source if you want. It handles the special JqueryUI widgets and also have an exceptional base class (which handled datepicker perfectly fine!) for all other widgets. I added a class for Tabs since the original author did not add one (and the base class did not handle it).
Edit: It looks like a LOT of code for a simply jquery widget. However, the classes allow you to nest things very very well, so you can create amazingly complex sets of widgets that would take hours and hours to do by hand.
@7oodauthorSep 27.2011 — #Thanks guys but you still didn't give me what i want ?, i am somehow new at php so i would want user to enter the date in the text field and then that number of days that the user entered is added to the current date, thats my problem, i don't want to write the number of days in the code i want to take it from users through a form thanks again!