Re: [PHP-DB] date function

2003-11-02 Thread Larry E . Ullman
This might not be the best place for this but here goes.
You are correct. At the very least, you should probably be using the 
general PHP list, not the database one.

I want to create a dropdown list with a date range of
Not to be obstinate, but it looks like you already have. But, assuming 
that you mean that you want to create this dynamically in PHP starting 
with today's date, then you need to establish some guidelines or rules 
for what dates make up the list. I can't really see a pattern in your 
list (every day for two weeks, then every week for five weeks, then two 
weeks once, then monthly going back a year) so I can't offer specifics. 
The answer will probably be found using a for loop and the date 
function.

Larry

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


Re: [PHP-DB] date function

2003-11-02 Thread Ignatius Reilly
have a look at the PEAR date package.
http://pear.php.net/package/Date

_
- Original Message -
From: OpenSource [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, November 02, 2003 11:13 PM
Subject: [PHP-DB] date function


Hi guys,

This might not be the best place for this but here goes.

I want to create a dropdown list with a date range of
--
SELECT name=bdate
 OPTION value=11/02/2003 SELECTEDToday
 OPTION value=11/01/2003Yesterday
 OPTION value=10/31/2003Fri 10/31
 OPTION value=10/30/2003Thu 10/30
 OPTION value=10/29/2003Wed 10/29
 OPTION value=10/28/2003Tue 10/28
 OPTION value=10/27/2003Mon 10/27
 OPTION value=10/26/2003Sun 10/26
 OPTION value=10/25/2003Sat 10/25
 OPTION value=10/24/2003Fri 10/24
 OPTION value=10/23/2003Thu 10/23
 OPTION value=10/22/2003Wed 10/22
 OPTION value=10/21/2003Tue 10/21
 OPTION value=10/20/2003Mon 10/20
 OPTION value=10/19/2003Sun 10/19
 OPTION value=10/12/2003Sun 10/12
 OPTION value=10/05/2003Sun 10/5
 OPTION value=09/28/2003Sun 9/28
 OPTION value=09/21/2003Sun 9/21
 OPTION value=09/14/2003Sun 9/14
 OPTION value=08/31/2003Sun 8/31
 OPTION value=08/01/2003Fri 8/1
 OPTION value=07/02/2003Wed 7/2
 OPTION value=06/02/2003Mon 6/2
 OPTION value=05/03/2003Sat 5/3
 OPTION value=04/03/2003Thu 4/3
 OPTION value=03/04/2003Tue 3/4
 OPTION value=02/02/2003Sun 2/2
 OPTION value=01/03/2003Fri 1/3
 OPTION value=12/04/2002Wed 12/4
/SELECT
--
I would like to know i can go about doing that. some examples, or if anyone
has a function already the i could use.


Thanks in advance,

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



Re: [PHP-DB] date function

2003-11-02 Thread Martin Marques
1) Why do you send this to a DB list?
2) Try seeing the Date class of PEAR (PEAR::Date).

El Dom 02 Nov 2003 19:13, OpenSource escribió:
 Hi guys,
 
 This might not be the best place for this but here goes.
 
 I want to create a dropdown list with a date range of
 --
 SELECT name=bdate
  OPTION value=11/02/2003 SELECTEDToday
  OPTION value=11/01/2003Yesterday
  OPTION value=10/31/2003Fri 10/31
  OPTION value=10/30/2003Thu 10/30
  OPTION value=10/29/2003Wed 10/29
  OPTION value=10/28/2003Tue 10/28
  OPTION value=10/27/2003Mon 10/27
  OPTION value=10/26/2003Sun 10/26
  OPTION value=10/25/2003Sat 10/25
  OPTION value=10/24/2003Fri 10/24
  OPTION value=10/23/2003Thu 10/23
  OPTION value=10/22/2003Wed 10/22
  OPTION value=10/21/2003Tue 10/21
  OPTION value=10/20/2003Mon 10/20
  OPTION value=10/19/2003Sun 10/19
  OPTION value=10/12/2003Sun 10/12
  OPTION value=10/05/2003Sun 10/5
  OPTION value=09/28/2003Sun 9/28
  OPTION value=09/21/2003Sun 9/21
  OPTION value=09/14/2003Sun 9/14
  OPTION value=08/31/2003Sun 8/31
  OPTION value=08/01/2003Fri 8/1
  OPTION value=07/02/2003Wed 7/2
  OPTION value=06/02/2003Mon 6/2
  OPTION value=05/03/2003Sat 5/3
  OPTION value=04/03/2003Thu 4/3
  OPTION value=03/04/2003Tue 3/4
  OPTION value=02/02/2003Sun 2/2
  OPTION value=01/03/2003Fri 1/3
  OPTION value=12/04/2002Wed 12/4
 /SELECT
 --
 I would like to know i can go about doing that. some examples, or if anyone 
has a function already the i could use.
 
 
 Thanks in advance,
 
 

-- 
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-
Martín Marqués  |[EMAIL PROTECTED]
Programador, Administrador, DBA |   Centro de Telemática
   Universidad Nacional
del Litoral
-

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



Re: [PHP-DB] date function

2003-09-05 Thread Jason Wong
On Saturday 06 September 2003 06:01, Darryl wrote:

 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
 trtd$name/ttd$timein/tdtd$cyear/tdtd$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 -MM-DD.  What have I screwed up ?

date() in php expects a unix timestamp. Dates in MySQL are NOT stored in unix 
timestamp format.

You can perform the calculations directly in MySQL

mysql manual  Tutorial Introduction  Date Calculations


-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
People with narrow minds usually have broad tongues.
*/

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