Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. .... instead$startDate = $monday->modify("tomorrow")->modify("last Monday")->format('Ymd');$endDate = $sunday->modify("yesterday")->modify("next Sunday")->format('Ymd');lot shorter
    I use your code and something is wrong-the tr element is not highlighted as expected,i think your code is OK, probably my syntax is somewhere wrong,Look at the code-it is short:
    $now = new DateTime($newdate);$today=$now->format('j m Y');$startDate = $mondayweek->modify("tomorrow")->modify("last Monday")->format('j m Y');$endDate =  $mondayweek->modify("yesterday")->modify("next Sunday")->format('j m Y');if(isset($_GET['month']))							   {echo  '<tr class="monthgreen" >';}							 elseif								 (isset($_GET['weekview']))								    {  								   if($today>= $startDate && $today <= $endDate)								    {echo   '<tr id="current_week" >';}								   else									   {echo '<tr class="john">';}									 }									 								   else								    echo '<tr class="john">';

    Instead of $current I used $now, it is better for me, for clarity reason. That is one thing.The other is the echo statements above where i got to implement the conditional you gave me. Do not be distracted from "monthgreen", this is for when the users are seeing the month-this is OK. What do you think? If there is a syntax error i cannot find it.

  2. You don't need to loop through current weekdays, just identify if current day falls between start - end dates, and apply id to tr element
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title> <style type="text/css"> .mytable td.weekdays {background-color:#FFFF99;}.mytable td.weekend {background-color: #FFCC99;}  .mytable #current_week td.weekdays, .mytable #current_week td.weekend  {background-color:#FF0033;} </style>  </head><body><?php$current = new DateTime;$monday   = new DateTime;$sunday   = new DateTime; $current = $current->format('Ymd'); // change from today to //$current = $current->modify("-1 week")->format('Ymd'); // last week $startDate = $monday->modify("tomorrow")->modify("last Monday")->format('Ymd');$endDate =   $sunday->modify("yesterday")->modify("next Sunday")->format('Ymd'); echo 'Monday = '.$startDate.'<br />';echo 'Sunday = '.$endDate.'<br />';echo 'current = '.$current.'<br />';?><table class="mytable"><tr><td class="weekdays">23</td><td class="weekdays">24</td><td class="weekdays">25</td><td class="weekdays">26</td><td class="weekdays">27</td><td class="weekend">28</td><td class="weekend">29</td></tr><?php if($current >= $startDate && $current <= $endDate){echo '<tr id="current_week">';}else{echo '<tr>';} ?><td class="weekdays">30</td><td class="weekdays">1</td><td class="weekdays">2</td><td class="weekdays">3</td><td class="weekdays">4</td><td class="weekend">5</td><td class="weekend">6</td></tr></table></body></html>

    Yes,that approach seems better,instead of looping through dates.There is one code segment i do not understand though.
    $startDate = $monday->modify("tomorrow")->modify("last Monday")->format('Ymd');$endDate =   $sunday->modify("yesterday")->modify("next Sunday")->format('Ymd');

    Why you want to use 2 modify methods,the one next to each other?Why not for example not use modify->(this monday), modify->(this sunday)? I miss something here.

  3. That works as well, but i gather $sunday1 is to do with another part of code somewhere else?
    What do you mean? Can you be more specific please?
  4. $now could be tuesday date, wednes.....etc therefore so will $monday, $sunday you have to define the actual monday and sunday values to get the range to loop through
    <?php$now = new DateTime;//$now->modify("+1 day");//$now->modify("+2 days");//$now->modify("+3 days");//$now->modify("+4 days");//$now->modify("+5 days");//$now->modify("+6 days");//$now->modify("+7 days"); $monday = clone $now;$monday->modify("+1 day")->modify("last Monday"); $sunday = clone $now;$sunday->modify("-1 day")->modify("next Sunday"); for ($day = clone $monday; $day <= $sunday; $day->modify('+1 day')) {echo $day->format('Y-m-d').'<br />';}?>

    the +1 and -1 days are used if on Monday, the last monday would the Monday week before, by going forward 1 day and selecting last Monday it becomes current last Monday, and then do reverse for Sunday.

    Yes you right to say that but i have already taken that into consideration. Look below and tell me what you think:
    $now = new DateTime($newdate);$week = $now->format('l') === 'Sunday' ? 'previous' : 'this';$monday = clone $now;$monday->modify('Monday ' . $week . ' week');$now->format('j');$sunday1=clone $now;$sunday1->modify('+7 days');$sunday = clone $now;$sunday->modify('Sunday ' . $week . ' week');

    SO, with the above code i make sure that "monday" DOES refer to monday and not "now", meaning today's date.

  5. The error seems to be caused by the echo, not the modify(). You need to explicitly call "format" upon echoing, like:
    $now = new DateTime; $monday = clone $now;$sunday = clone $now;for ($day = clone $monday; $day < $sunday; $day->modify('+1 day')) {echo $day->format('Y-m-d');}

    But that's shouldn't even enter the loop once, since $day will always be equal to $sunday rather than less than it. You'd have to modify $sunday, so that it's later than $monday, like:

    $now = new DateTime; $monday = clone $now;$sunday = clone $now;$sunday->modify('+7 days'); for ($day = clone $monday; $day < $sunday; $day->modify('+1 day')) {echo $day->format('Y-m-d');}

    At last, now it works,thanks. :happy0046:Now i want to see sth in Dsonesuk's code.
  6. I keep forgetting that clone is a keyword, and not a type :facepalm: (I don't do much cloning...). And I also forgot I switched between variable names, so... khmm... try it like this:
    for ($day = clone $monday; $day < $sunday; $day->modify('+1 day')) {}

    (notice the middle part of the "for")

    It does not work, i get the same message:Catchable fatal error: Object of class DateTime could not be converted to string in C:\xampp\htdocs\korakeiko\timetest3.php on line 14 Here is the whole code:
     $now = new DateTime;$week = $now->format('d-m-y') === 'Sunday' ? 'previous' : 'this';$monday = clone $now;$monday->modify('Monday ' . $week . ' week'); $sunday = clone $now;$sunday->modify('Sunday ' . $week . ' week');

    I cannot understand why $day->modify('+1 day')) cannot be converted to a string.

  7. You don't need to loop through current weekdays, just identify if current day falls between start - end dates, and apply id to tr element .....................
    Regarding your code Dsonesuk i will see it later-i want to see first boen_robot's code(for educational purposes.)
    If you want to include PHP 5.2.2 as well, you could use something like this:
    for ($day = (clone)$monday; $current < $sunday; $day->modify('+1 day')) {/* $day will contain a DateTime representing each day between Monday and Saturday.If you want to include Sunday, add one day to $sunday before the loop OR use "<=" instead of "<".*/}

    I tried the above code and the browser outputs that there is syntax error: Parse error: syntax error, unexpected ')' in C:\xampp\htdocs\korakeiko\timetest3.php on line I then tried for ($day = clone $monday; $current < $sunday; $day->modify('+1 day')) and i got the message that Catchable fatal error: Object of class DateTime could not be converted to string in C:\xampp\htdocs\korakeiko\timetest3.php on line Finally i tried for ($day = clone $monday->format('d-m-y'); $current < $sunday->format('d-m-y') ; $day->modify('+1 day')) abd then i got Fatal error: __clone method called on non-object in C:\xampp\htdocs\korakeiko\timetest3.php on line 16 There must be a problem with the object definition,i tried some things but i would appreciate some help.
  8. I want to take the dated between 2 dates that lie far left and far right of a specific date interval. For example i want to dates between 4-30-2012 and 5-5-2012. I found in the web the following code which works:

    $startDate = '4-30-2012';$endDate ='5-5-2012';for($current = $startDate ; $current != $endDate ; $current = date('d-m-Y', strtotime("$current +1 day")))   {echo $current.'<br>';

    The problem is that i cannot do the above code work if instead of using date strings i use methods of the datelclass such as $monday->format('Y m d') or $sunday->format('Y m d') which both output date strings, Basically here is what i was trying to achieve:

    $startDate =  [b]$monday->format('Y m d') [/b];$endDate = $[b]sunday->format('Y m d') [/b]';for($current = $startDate ; $current != $endDate ; $current = date('d-m-Y', strtotime("$current +1 day")))   {echo $current.'<br>';

    What do you think? How am i going to take the date range between $monday->format('Y m d') and $sunday->format('Y m d') ? I think, that he above code does not work because strtotime cannot be used with methods such as these of the dateclass shown here.

  9. That's odd given PHP 5.4.1RC2's change log... oh well... php5apache2_3.dll (Apache 2.3 is the "beta" version of Apache 2.4; this DLL should be compatible with 2.4)? As for the coming out in 2 days... that's what the front page on php.net says:
    Since the dll(i can neither find php5apache2_3.dll) was not found i will have to wait for the final version in 2 days. And to be precise that we are talking about the same thing, here is the name of the file i downloaded: php-5.4.1RC2.tar.
  10. You have two options: 1. Get the PHP 5.4.1RC2 (or wait 2 more days for the final PHP 5.4.1 to come out), and use the php5apache2_4.dll in it.
    Are you sure it will come out in 2 days? I followed option 1 but there was not any php5apache2_4.dll in the php folder?
  11. The problem continues.Apache does not restart. A window appears telling "Requested operation has failed"I tried to start Apache from the command prompt and here is the message that i got

    C:\Apache24\bin>httpd.exehttpd.exe: Syntax error on line 1 of C:/Apache24/conf/httpd.conf: Cannot load C:/php/php5apache2_2.dll into server: \xc4\xe5\xed \xde\xf4\xe1\xed \xe4\xf5\xed\xe1\xf4\xfc \xed\xe1 \xe5\xed\xf4\xef\xf0\xe9\xf3\xf4\xe5\xdf \xe7 \xea\xe1\xe8\xef\xf1\xe9\xf3\xec\xdd\xed\xe7 \xe4\xe9\xe1\xe4\xe9\xea\xe1\xf3\xdf\xe1. C:\Apache24\bin>

    Here is line 1LoadModule php5_module "C:\php\php5apache2_2.dll" Do you see any syntax error in the above line? The whole code of course that goes to apache config is the:

    LoadModule php5_module "C:\php\php5apache2_2.dll"AddType application\x-httpd-php.phpPHPIniDir "C:\php"

    I even tried changing the slashes from back ones to forward ones but without any result.

  12. I am in the proccess of installing separately pache,php and mysql. I downloaded apache from here http://www.apachelounge.com/download/win64/and php from here http://windows.php.net/download/ as boen robot suggested I am reading this tutorial here:http://www.ricocheting.com/how-to-install-on-windows/php I installed apache successfully but i cannot install php. The problem arises when following step 5(in "installing PHP")-after i do thatApache will not restart-i have downloaded php thread safe, so this is the correct version.

  13. Well, you'll have to manually install MySQL also... but that's the easiest part of the whole process - you just download the MSI from MySQL's site, press "Next" on all dialogs, and you're done. Other than that... let's see... [opens up Apachefriend's home page and XAMPP's page]- phpMyAdmin - OK, yes, if you want to use that, you'd have to install it manually. Personally, I prefer to use MySQL Workbench, which in addition to being generally more awesome is also easier to install (another MSI file...).- OpenSSL - The ApacheLounge binary includes it (for HTTPS serving's sake), and the PHP archive also includes it (for HTTPS consumption's sake).- XAMPP Control Panel - obviously, no. But honestly, how much have you used that control panel? Only to occasionally restart Apache? There's the Apache monitor tool for that... I believe it was part of the ApacheLounge binary.- Strawberry Perl - you don't use Perl, do you?- FileZilla FTP Server - If you only access your files locally, you don't need it. If you absolutely need an FTP server on your home computer, installation is trivial.- Tomcat 7.0.21 - do you use JSP? If not, you don't need that.
    Ok, all in all, you are saying that installing components separately is better(since some are not needed)-and not difficult.And another thing, since I already have 3 local sites,do you thing it will be difficult to transfer them in this new setting you are mentioning. This last is what bothers me most.
  14. PHP - the language - is interpreted by an interpreter.PHP - the interpreter - is written in the C language, which is compiled. What you have on your machine is a version of the PHP interpreter. That interpreter itself is considered to be "compiled/built" since it was produced by a compiler. You don't have a compiler. So, when the page says It's referring to the thing that produced the interpreter. You don't upgrade the compiler, since you don't have one. You upgrade the interpreter with another one that was generated by another compiler.
    Good explanation
    Since you're currently using XAMPP, it might be a better idea to uninstall it before you continue, and then install Apache separately. A compilation of Apache built with VC9 that PHP recommends is ApacheLounge's compilation. Installation instructions are found within the zip archive. PHP builds are found on a separate page on the PHP site. Since you'll be using ApacheLounge's build, you'll need the "VC9 x86 Thread Safe" build. The "VC9" part is important for XDebug, and the "Thread Safe" part is important for Apache.
    Are you sure this is the way to go, in other words you are saying to get rid of XAMPP, yes, but what if XAMP offers some features that are really needed and this ad hoc solution you propose does not. I have set 3 local sites with XAMPP and I am intimidated having to set up these again "manually". I am just asking.
  15. I just run this tool here http://xdebug.org/wizard.php and here is the message i get: The compiler (MS VC6) that this PHP was build with, is no longer supported. Please upgrade to a version that was built with MS VC9. It seems there is a problem with the compiler and i cannot install xdebug unless upgrading. The question is how i upgrade the compiler, do i just upgrade PHP(i have PHP 5.3 running on XAMPP)? I have never upgraded PHP on XAMP, how am i going to do it? Do i just unzip in the specified folder? P.S One last question, since PHP is interpreted why a compiler is needed?

  16. I am using netbeans to develop PHP applications and now i am in search of a good debugger. In the Netbeans site Xdebug is proposed as a debugger but i am interested also on what you have to say. Thanks.

×
×
  • Create New...