date function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings,
I have some php code that pulls from the mysql database.  Here it is:

<?php
         mysql_connect("wildcat.osborneindustries.com", "webuser",
"webpass");
   $mymonth = date('n');
   $cyear = date('Y');
         $query = "SELECT name,hdate FROM emp2 where month(hdate)=$mymonth
order by hdate";
         $result = mysql_db_query("iweb", $query);

         if ($result) {
           echo "<table align=center  border=0  cellspacing=5 >";
           while ($r = mysql_fetch_array($result)) {
              $name = $r["name"];
     $hyear = date('Y',$r["hdate"]);
     $timein = $cyear - $hyear;
     if ($timein > 0) {
                echo
"<tr><td>$name</t><td>$timein</td><td>$cyear</td><td>$hyear</td></tr>";}
           }
           echo "</table>";
         } else {
        echo "No data.";
    }
    mysql_free_result($result); ?>

I'm trying to figure out years of employment based on hiredate.  Its not
working as expected.  $timein is always
1969.  Date in the database is YYYY-MM-DD.  What have I screwed up ?

thanks,
Darryl

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux