RE: [PHP] Query question

2006-10-30 Thread Ivo F.A.C. Fokkema
On Sun, 29 Oct 2006 23:04:27 -0600, Richard Lynch wrote:
> On Sun, October 29, 2006 2:06 am, Beauford wrote:
>> LOL, I don't know either. The format is - 01/01/2006. When I first did
>> it I
>> used 7, which should be right, but I ended up getting /2002 /2003,
>> etc. So I
>> went to 8 and all was well. Beats me.
> 
> Dollars to donuts says your 'date' (which is really a string) has some
> leading spaces which is messing up your count...
> 
> Of course, after you fix the import process to have an actual DATE in
> your DB, this will be a non-issue...
> 
> Short-term, you should probably at least trim() the data so that your
> offset of 8 is the number you would expect...

Or, you use RIGHT(date, 4) as I believe MySQL always automatically removes
trailing spaces in VARCHAR columns. It will save you the use of one
additional function and RIGHT() may even be faster than SUBSTRING()
because it doesn't need to go through the entire string. But that's just
guessing and I think you probably won't even notice this in microseconds :)

Ivo

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



RE: [PHP] Query question

2006-10-29 Thread Richard Lynch
On Sun, October 29, 2006 2:06 am, Beauford wrote:
> This is how I get the data and I have no control over the actual
> layout of
> the database. So I have to work with what I have.

When you say it's "how you get the data" are they handing you a MySQL
database that is this badly-constructed?

Or are you importing data whose dates are in 'mm/dd/' format, and
failing to realize that you CAN and SHOULD convert those to date as
part of your import process.

> LOL, I don't know either. The format is - 01/01/2006. When I first did
> it I
> used 7, which should be right, but I ended up getting /2002 /2003,
> etc. So I
> went to 8 and all was well. Beats me.

Dollars to donuts says your 'date' (which is really a string) has some
leading spaces which is messing up your count...

Of course, after you fix the import process to have an actual DATE in
your DB, this will be a non-issue...

Short-term, you should probably at least trim() the data so that your
offset of 8 is the number you would expect...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Query question

2006-10-29 Thread Ed Lazor
You'd still benefit from converting your data into an actual date  
format in order to take full advantage of available features.  hehe  
You guys are going to start thinking of me as a performance freak,  
but I think MySQL's date functions might provide better performance  
than string manipulation.



On Oct 29, 2006, at 6:08 AM, Beauford wrote:

I don't see this as a particular problem as the data will always be  
the
same. Now under other circumstances in another database, I can see  
what you

are saying.

-Original Message-
From: Satyam [mailto:[EMAIL PROTECTED]
Sent: October 29, 2006 4:30 AM
To: Beauford; 'PHP'
Subject: Re: [PHP] Query question

I said that you have a problem,not that you caused it, and my  
observation

might (hopefully) help newbies in the list.

Satyam


- Original Message -
From: "Beauford" <[EMAIL PROTECTED]>
To: "'PHP'" 
Sent: Sunday, October 29, 2006 9:06 AM
Subject: RE: [PHP] Query question


This is how I get the data and I have no control over the actual  
layout of

the database. So I have to work with what I have.

Robert:

LOL, I don't know either. The format is - 01/01/2006. When I first  
did it

I
used 7, which should be right, but I ended up getting /2002 /2003,  
etc. So



I
went to 8 and all was well. Beats me.


B

-Original Message-
From: Satyam [mailto:[EMAIL PROTECTED]
Sent: October 29, 2006 2:14 AM
To: Beauford; 'PHP'
Subject: Re: [PHP] Query question

If that works then you have a problem:  you are storing dates as a  
plain

string ( varchar or whatever) instead of a native date/time datatype,
which
precludes the use of a large number of native SQL date/time  
functions,

such
as year() which should suit you nicely in this case.  Eventually,  
you will
bump into something more elaborate which you won't be able to do  
on the

SQL
side just with string functions and that will force you to bring  
whole

tables into PHP to do more extensive processing.

Satyam

- Original Message -
From: "Beauford" <[EMAIL PROTECTED]>
To: "'PHP'" 
Sent: Sunday, October 29, 2006 7:05 AM
Subject: RE: [PHP] Query question



This is what I finally figured out, which works just perfectly.

select count(date) as count, substring(date,8) as year from stats  
group

by
year;

Thanks to all for the input.

-Original Message-----
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 29, 2006 12:15 AM
To: Beauford
Cc: PHP
Subject: Re: [PHP] Query question

Look into the MySQL YEAR() function to extract the year from a  
specific

date.
Start here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:


I posted this here as I figured I would need to manipulate this  
using

PHP.
The code below doesn't quite work because the date is in the  
format of

05/05/2006. So I am getting totals for each date, not each year. I
need the totals for each year, regardless of the day or month.  
This is
why I figured I'd need to use PHP to maybe put it in an array  
first or

something.

Thanks

-Original Message-
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 28, 2006 10:30 PM
To: Ed Lazor
Cc: Beauford; PHP
Subject: Re: [PHP] Query question

Agreed, this should go to a MySQL list. But in the spirit of  
helping I

think the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY  
`year` ASC



On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:


Use the mysql list :)


On Oct 28, 2006, at 3:01 PM, Beauford wrote:


Hi,

I have a MySQL database with a date field and a bunch of other
fields. The date field is in the format - 01/01/2006. What I want
to do is query the database and create a table that shows just  
the

year and how many instances of the year there is. I have been
taxing my brain for a simple solution, but just not getting it.
Any suggestions?

Thanks

Example output.

Year  Count

2002  5
2003  8
2004  9
2005  15
2006  22

ps - I get this information sent to me and I can't change any of
the data. I just enter it in the db and then hopefully do the
query on it.




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

http://www.php.net/unsub.php




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

http://www.php.net/unsub.php




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





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

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




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

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



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



RE: [PHP] Query question

2006-10-29 Thread Beauford
I don't see this as a particular problem as the data will always be the
same. Now under other circumstances in another database, I can see what you
are saying.  

-Original Message-
From: Satyam [mailto:[EMAIL PROTECTED] 
Sent: October 29, 2006 4:30 AM
To: Beauford; 'PHP'
Subject: Re: [PHP] Query question

I said that you have a problem,not that you caused it, and my observation
might (hopefully) help newbies in the list.

Satyam


- Original Message -
From: "Beauford" <[EMAIL PROTECTED]>
To: "'PHP'" 
Sent: Sunday, October 29, 2006 9:06 AM
Subject: RE: [PHP] Query question


> This is how I get the data and I have no control over the actual layout of
> the database. So I have to work with what I have.
>
> Robert:
>
> LOL, I don't know either. The format is - 01/01/2006. When I first did it 
> I
> used 7, which should be right, but I ended up getting /2002 /2003, etc. So

> I
> went to 8 and all was well. Beats me.
>
>
> B
>
> -Original Message-
> From: Satyam [mailto:[EMAIL PROTECTED]
> Sent: October 29, 2006 2:14 AM
> To: Beauford; 'PHP'
> Subject: Re: [PHP] Query question
>
> If that works then you have a problem:  you are storing dates as a plain
> string ( varchar or whatever) instead of a native date/time datatype, 
> which
> precludes the use of a large number of native SQL date/time functions, 
> such
> as year() which should suit you nicely in this case.  Eventually, you will
> bump into something more elaborate which you won't be able to do on the 
> SQL
> side just with string functions and that will force you to bring whole
> tables into PHP to do more extensive processing.
>
> Satyam
>
> - Original Message -
> From: "Beauford" <[EMAIL PROTECTED]>
> To: "'PHP'" 
> Sent: Sunday, October 29, 2006 7:05 AM
> Subject: RE: [PHP] Query question
>
>
>> This is what I finally figured out, which works just perfectly.
>>
>> select count(date) as count, substring(date,8) as year from stats group 
>> by
>> year;
>>
>> Thanks to all for the input.
>>
>> -Original Message-
>> From: Joe Wollard [mailto:[EMAIL PROTECTED]
>> Sent: October 29, 2006 12:15 AM
>> To: Beauford
>> Cc: PHP
>> Subject: Re: [PHP] Query question
>>
>> Look into the MySQL YEAR() function to extract the year from a specific
>> date.
>> Start here:
>> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
>>
>>
>>
>>
>> On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:
>>>
>>> I posted this here as I figured I would need to manipulate this using
>>> PHP.
>>> The code below doesn't quite work because the date is in the format of
>>> 05/05/2006. So I am getting totals for each date, not each year. I
>>> need the totals for each year, regardless of the day or month. This is
>>> why I figured I'd need to use PHP to maybe put it in an array first or
>>> something.
>>>
>>> Thanks
>>>
>>> -Original Message-
>>> From: Joe Wollard [mailto:[EMAIL PROTECTED]
>>> Sent: October 28, 2006 10:30 PM
>>> To: Ed Lazor
>>> Cc: Beauford; PHP
>>> Subject: Re: [PHP] Query question
>>>
>>> Agreed, this should go to a MySQL list. But in the spirit of helping I
>>> think the following should give you a good starting point.
>>>
>>> SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC
>>>
>>>
>>> On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>>> >
>>> > Use the mysql list :)
>>> >
>>> >
>>> > On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>>> >
>>> > > Hi,
>>> > >
>>> > > I have a MySQL database with a date field and a bunch of other
>>> > > fields. The date field is in the format - 01/01/2006. What I want
>>> > > to do is query the database and create a table that shows just the
>>> > > year and how many instances of the year there is. I have been
>>> > > taxing my brain for a simple solution, but just not getting it.
>>> > > Any suggestions?
>>> > >
>>> > > Thanks
>>> > >
>>> > > Example output.
>>> > >
>>> > > Year  Count
>>> > >
>>> > > 2002  5
>>> > > 2003  8
>>> > > 2004  9
>>> > > 2005  15
>>> > > 2006 

Re: [PHP] Query question

2006-10-29 Thread Satyam
I said that you have a problem,not that you caused it, and my observation 
might (hopefully) help newbies in the list.


Satyam


- Original Message - 
From: "Beauford" <[EMAIL PROTECTED]>

To: "'PHP'" 
Sent: Sunday, October 29, 2006 9:06 AM
Subject: RE: [PHP] Query question



This is how I get the data and I have no control over the actual layout of
the database. So I have to work with what I have.

Robert:

LOL, I don't know either. The format is - 01/01/2006. When I first did it 
I
used 7, which should be right, but I ended up getting /2002 /2003, etc. So 
I

went to 8 and all was well. Beats me.


B

-Original Message-
From: Satyam [mailto:[EMAIL PROTECTED]
Sent: October 29, 2006 2:14 AM
To: Beauford; 'PHP'
Subject: Re: [PHP] Query question

If that works then you have a problem:  you are storing dates as a plain
string ( varchar or whatever) instead of a native date/time datatype, 
which
precludes the use of a large number of native SQL date/time functions, 
such

as year() which should suit you nicely in this case.  Eventually, you will
bump into something more elaborate which you won't be able to do on the 
SQL

side just with string functions and that will force you to bring whole
tables into PHP to do more extensive processing.

Satyam

- Original Message -
From: "Beauford" <[EMAIL PROTECTED]>
To: "'PHP'" 
Sent: Sunday, October 29, 2006 7:05 AM
Subject: RE: [PHP] Query question



This is what I finally figured out, which works just perfectly.

select count(date) as count, substring(date,8) as year from stats group 
by

year;

Thanks to all for the input.

-Original Message-
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 29, 2006 12:15 AM
To: Beauford
Cc: PHP
Subject: Re: [PHP] Query question

Look into the MySQL YEAR() function to extract the year from a specific
date.
Start here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:


I posted this here as I figured I would need to manipulate this using
PHP.
The code below doesn't quite work because the date is in the format of
05/05/2006. So I am getting totals for each date, not each year. I
need the totals for each year, regardless of the day or month. This is
why I figured I'd need to use PHP to maybe put it in an array first or
something.

Thanks

-Original Message-
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 28, 2006 10:30 PM
To: Ed Lazor
Cc: Beauford; PHP
Subject: Re: [PHP] Query question

Agreed, this should go to a MySQL list. But in the spirit of helping I
think the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>
> Use the mysql list :)
>
>
> On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>
> > Hi,
> >
> > I have a MySQL database with a date field and a bunch of other
> > fields. The date field is in the format - 01/01/2006. What I want
> > to do is query the database and create a table that shows just the
> > year and how many instances of the year there is. I have been
> > taxing my brain for a simple solution, but just not getting it.
> > Any suggestions?
> >
> > Thanks
> >
> > Example output.
> >
> > Year  Count
> >
> > 2002  5
> > 2003  8
> > 2004  9
> > 2005  15
> > 2006  22
> >
> > ps - I get this information sent to me and I can't change any of
> > the data. I just enter it in the db and then hopefully do the
> > query on it.
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>

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




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





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

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




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



RE: [PHP] Query question

2006-10-29 Thread Beauford
This is how I get the data and I have no control over the actual layout of
the database. So I have to work with what I have. 

Robert:

LOL, I don't know either. The format is - 01/01/2006. When I first did it I
used 7, which should be right, but I ended up getting /2002 /2003, etc. So I
went to 8 and all was well. Beats me.


B

-Original Message-
From: Satyam [mailto:[EMAIL PROTECTED] 
Sent: October 29, 2006 2:14 AM
To: Beauford; 'PHP'
Subject: Re: [PHP] Query question

If that works then you have a problem:  you are storing dates as a plain
string ( varchar or whatever) instead of a native date/time datatype, which
precludes the use of a large number of native SQL date/time functions, such
as year() which should suit you nicely in this case.  Eventually, you will
bump into something more elaborate which you won't be able to do on the SQL
side just with string functions and that will force you to bring whole
tables into PHP to do more extensive processing.

Satyam

- Original Message -
From: "Beauford" <[EMAIL PROTECTED]>
To: "'PHP'" 
Sent: Sunday, October 29, 2006 7:05 AM
Subject: RE: [PHP] Query question


> This is what I finally figured out, which works just perfectly.
>
> select count(date) as count, substring(date,8) as year from stats group by
> year;
>
> Thanks to all for the input.
>
> -Original Message-
> From: Joe Wollard [mailto:[EMAIL PROTECTED]
> Sent: October 29, 2006 12:15 AM
> To: Beauford
> Cc: PHP
> Subject: Re: [PHP] Query question
>
> Look into the MySQL YEAR() function to extract the year from a specific
> date.
> Start here:
> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
>
>
>
>
> On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:
>>
>> I posted this here as I figured I would need to manipulate this using 
>> PHP.
>> The code below doesn't quite work because the date is in the format of
>> 05/05/2006. So I am getting totals for each date, not each year. I
>> need the totals for each year, regardless of the day or month. This is
>> why I figured I'd need to use PHP to maybe put it in an array first or
>> something.
>>
>> Thanks
>>
>> -Original Message-
>> From: Joe Wollard [mailto:[EMAIL PROTECTED]
>> Sent: October 28, 2006 10:30 PM
>> To: Ed Lazor
>> Cc: Beauford; PHP
>> Subject: Re: [PHP] Query question
>>
>> Agreed, this should go to a MySQL list. But in the spirit of helping I
>> think the following should give you a good starting point.
>>
>> SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC
>>
>>
>> On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>> >
>> > Use the mysql list :)
>> >
>> >
>> > On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>> >
>> > > Hi,
>> > >
>> > > I have a MySQL database with a date field and a bunch of other
>> > > fields. The date field is in the format - 01/01/2006. What I want
>> > > to do is query the database and create a table that shows just the
>> > > year and how many instances of the year there is. I have been
>> > > taxing my brain for a simple solution, but just not getting it.
>> > > Any suggestions?
>> > >
>> > > Thanks
>> > >
>> > > Example output.
>> > >
>> > > Year  Count
>> > >
>> > > 2002  5
>> > > 2003  8
>> > > 2004  9
>> > > 2005  15
>> > > 2006  22
>> > >
>> > > ps - I get this information sent to me and I can't change any of
>> > > the data. I just enter it in the db and then hopefully do the
>> > > query on it.
>> > >
>> > >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
>> > http://www.php.net/unsub.php
>> >
>> >
>>
>> --
>> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
>> http://www.php.net/unsub.php
>>
>>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> 

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

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



Re: [PHP] Query question

2006-10-29 Thread Satyam
If that works then you have a problem:  you are storing dates as a plain 
string ( varchar or whatever) instead of a native date/time datatype, which 
precludes the use of a large number of native SQL date/time functions, such 
as year() which should suit you nicely in this case.  Eventually, you will 
bump into something more elaborate which you won't be able to do on the SQL 
side just with string functions and that will force you to bring whole 
tables into PHP to do more extensive processing.


Satyam

- Original Message - 
From: "Beauford" <[EMAIL PROTECTED]>

To: "'PHP'" 
Sent: Sunday, October 29, 2006 7:05 AM
Subject: RE: [PHP] Query question



This is what I finally figured out, which works just perfectly.

select count(date) as count, substring(date,8) as year from stats group by
year;

Thanks to all for the input.

-Original Message-
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 29, 2006 12:15 AM
To: Beauford
Cc: PHP
Subject: Re: [PHP] Query question

Look into the MySQL YEAR() function to extract the year from a specific
date.
Start here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:


I posted this here as I figured I would need to manipulate this using 
PHP.

The code below doesn't quite work because the date is in the format of
05/05/2006. So I am getting totals for each date, not each year. I
need the totals for each year, regardless of the day or month. This is
why I figured I'd need to use PHP to maybe put it in an array first or
something.

Thanks

-Original Message-
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 28, 2006 10:30 PM
To: Ed Lazor
Cc: Beauford; PHP
Subject: Re: [PHP] Query question

Agreed, this should go to a MySQL list. But in the spirit of helping I
think the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>
> Use the mysql list :)
>
>
> On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>
> > Hi,
> >
> > I have a MySQL database with a date field and a bunch of other
> > fields. The date field is in the format - 01/01/2006. What I want
> > to do is query the database and create a table that shows just the
> > year and how many instances of the year there is. I have been
> > taxing my brain for a simple solution, but just not getting it.
> > Any suggestions?
> >
> > Thanks
> >
> > Example output.
> >
> > Year  Count
> >
> > 2002  5
> > 2003  8
> > 2004  9
> > 2005  15
> > 2006  22
> >
> > ps - I get this information sent to me and I can't change any of
> > the data. I just enter it in the db and then hopefully do the
> > query on it.
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>

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




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





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



RE: [PHP] Query question

2006-10-29 Thread Robert Cummings
On Sun, 2006-10-29 at 01:05 -0500, Beauford wrote:
> This is what I finally figured out, which works just perfectly.
> 
> select count(date) as count, substring(date,8) as year from stats group by
> year;
> 
> Thanks to all for the input.

So what you're saying is that you're not using a date field, you're
using some kind of string concoction where the year information happens
to start at the 8th character? Now that gets me wondering what kind of
freaky date format you've used :) I mean I could naturally see the 5th
or 7th character being the start point for the year using the following
formats respectively:

ddmm

dd/mm/

But you're grabbing from the 8th character onwards which just seems
wierd.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



RE: [PHP] Query question

2006-10-28 Thread Beauford
This is what I finally figured out, which works just perfectly.

select count(date) as count, substring(date,8) as year from stats group by
year;

Thanks to all for the input.

-Original Message-
From: Joe Wollard [mailto:[EMAIL PROTECTED] 
Sent: October 29, 2006 12:15 AM
To: Beauford
Cc: PHP
Subject: Re: [PHP] Query question

Look into the MySQL YEAR() function to extract the year from a specific
date.
Start here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:
>
> I posted this here as I figured I would need to manipulate this using PHP.
> The code below doesn't quite work because the date is in the format of 
> 05/05/2006. So I am getting totals for each date, not each year. I 
> need the totals for each year, regardless of the day or month. This is 
> why I figured I'd need to use PHP to maybe put it in an array first or 
> something.
>
> Thanks
>
> -Original Message-
> From: Joe Wollard [mailto:[EMAIL PROTECTED]
> Sent: October 28, 2006 10:30 PM
> To: Ed Lazor
> Cc: Beauford; PHP
> Subject: Re: [PHP] Query question
>
> Agreed, this should go to a MySQL list. But in the spirit of helping I 
> think the following should give you a good starting point.
>
> SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC
>
>
> On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
> >
> > Use the mysql list :)
> >
> >
> > On Oct 28, 2006, at 3:01 PM, Beauford wrote:
> >
> > > Hi,
> > >
> > > I have a MySQL database with a date field and a bunch of other 
> > > fields. The date field is in the format - 01/01/2006. What I want 
> > > to do is query the database and create a table that shows just the 
> > > year and how many instances of the year there is. I have been 
> > > taxing my brain for a simple solution, but just not getting it. 
> > > Any suggestions?
> > >
> > > Thanks
> > >
> > > Example output.
> > >
> > > Year  Count
> > >
> > > 2002  5
> > > 2003  8
> > > 2004  9
> > > 2005  15
> > > 2006  22
> > >
> > > ps - I get this information sent to me and I can't change any of 
> > > the data. I just enter it in the db and then hopefully do the 
> > > query on it.
> > >
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> > http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>

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



Re: [PHP] Query question

2006-10-28 Thread Joe Wollard

Look into the MySQL YEAR() function to extract the year from a specific
date.
Start here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:


I posted this here as I figured I would need to manipulate this using PHP.
The code below doesn't quite work because the date is in the format of
05/05/2006. So I am getting totals for each date, not each year. I need
the
totals for each year, regardless of the day or month. This is why I
figured
I'd need to use PHP to maybe put it in an array first or something.

Thanks

-Original Message-
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 28, 2006 10:30 PM
To: Ed Lazor
Cc: Beauford; PHP
Subject: Re: [PHP] Query question

Agreed, this should go to a MySQL list. But in the spirit of helping I
think
the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>
> Use the mysql list :)
>
>
> On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>
> > Hi,
> >
> > I have a MySQL database with a date field and a bunch of other
> > fields. The date field is in the format - 01/01/2006. What I want to
> > do is query the database and create a table that shows just the year
> > and how many instances of the year there is. I have been taxing my
> > brain for a simple solution, but just not getting it. Any
> > suggestions?
> >
> > Thanks
> >
> > Example output.
> >
> > Year  Count
> >
> > 2002  5
> > 2003  8
> > 2004  9
> > 2005  15
> > 2006  22
> >
> > ps - I get this information sent to me and I can't change any of the
> > data. I just enter it in the db and then hopefully do the query on
> > it.
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>

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




RE: [PHP] Query question

2006-10-28 Thread Beauford
I posted this here as I figured I would need to manipulate this using PHP.
The code below doesn't quite work because the date is in the format of
05/05/2006. So I am getting totals for each date, not each year. I need the
totals for each year, regardless of the day or month. This is why I figured
I'd need to use PHP to maybe put it in an array first or something. 

Thanks

-Original Message-
From: Joe Wollard [mailto:[EMAIL PROTECTED] 
Sent: October 28, 2006 10:30 PM
To: Ed Lazor
Cc: Beauford; PHP
Subject: Re: [PHP] Query question

Agreed, this should go to a MySQL list. But in the spirit of helping I think
the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>
> Use the mysql list :)
>
>
> On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>
> > Hi,
> >
> > I have a MySQL database with a date field and a bunch of other 
> > fields. The date field is in the format - 01/01/2006. What I want to 
> > do is query the database and create a table that shows just the year 
> > and how many instances of the year there is. I have been taxing my 
> > brain for a simple solution, but just not getting it. Any 
> > suggestions?
> >
> > Thanks
> >
> > Example output.
> >
> > Year  Count
> >
> > 2002  5
> > 2003  8
> > 2004  9
> > 2005  15
> > 2006  22
> >
> > ps - I get this information sent to me and I can't change any of the 
> > data. I just enter it in the db and then hopefully do the query on 
> > it.
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>

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



Re: [PHP] Query question

2006-10-28 Thread Joe Wollard

Agreed, this should go to a MySQL list. But in the spirit of helping I think
the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:


Use the mysql list :)


On Oct 28, 2006, at 3:01 PM, Beauford wrote:

> Hi,
>
> I have a MySQL database with a date field and a bunch of other
> fields. The
> date field is in the format - 01/01/2006. What I want to do is
> query the
> database and create a table that shows just the year and how many
> instances
> of the year there is. I have been taxing my brain for a simple
> solution, but
> just not getting it. Any suggestions?
>
> Thanks
>
> Example output.
>
> Year  Count
>
> 2002  5
> 2003  8
> 2004  9
> 2005  15
> 2006  22
>
> ps - I get this information sent to me and I can't change any of
> the data. I
> just enter it in the db and then hopefully do the query on it.
>
>

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




Re: [PHP] Query question

2006-10-28 Thread Ed Lazor

Use the mysql list :)


On Oct 28, 2006, at 3:01 PM, Beauford wrote:


Hi,

I have a MySQL database with a date field and a bunch of other  
fields. The
date field is in the format - 01/01/2006. What I want to do is  
query the
database and create a table that shows just the year and how many  
instances
of the year there is. I have been taxing my brain for a simple  
solution, but

just not getting it. Any suggestions?

Thanks

Example output.

YearCount

20025
20038
20049
200515
200622

ps - I get this information sent to me and I can't change any of  
the data. I

just enter it in the db and then hopefully do the query on it.




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



RE: [PHP] Query Question

2004-08-11 Thread Karl-Heinz Schulz
I found my problem.



$eventdetail_query = mysql_query("select DISTINCT titles, informations,
file_name from eventdetail, event where eventdetail.event = ".$id);

-Original Message-
From: Karl-Heinz Schulz [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 11, 2004 10:13 PM
To: 'Jason Davidson'
Subject: RE: [PHP] Query Question

Oops - it shows all the "eventdetails" for all the "events"

-Original Message-
From: Jason Davidson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 11, 2004 10:10 PM
To: Karl-Heinz Schulz; [EMAIL PROTECTED]
Subject: Re: [PHP] Query Question

whats the error, are there any matching fields for the columns
eventetail.event and event.id?
Jason

"Karl-Heinz Schulz" <[EMAIL PROTECTED]> wrote: 
> 
> Why does this query not work?
> It should only show the eventdetails for the shown event.
> 
>

> -
> 
>  $event = mysql_query("select id, information from event where id=".$id);  
> ?>
>  
> $eventdetail_query = mysql_query("select titles, informations, file_name
> from eventdetail, event where eventdetail.event = event.id");
> 
> while($eventdetail = mysql_fetch_row($eventdetail_query)){ 
> 
> 
> print(" sans-serif;font-size:12px;\"> href=\"../PDF/$eventdetail[2]\"
>
class=\"decisions_links\">".strip_tags(html_decode($eventdetail[0]))." span>");
> print("  sans-serif;font-size:12px;\">".html_decode($eventdetail[1])."");
> 
>  }
> 
>  ?>
> 
>

> -
> 
> 
> TIA
> 
> Karl-Heinz
> 
> 
> 
> 
> Tracking #: B3BFF38AEF0C854C96E9B501DD35C6C783308CA5
> 
> 

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

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



Re: [PHP] Query Question

2004-08-11 Thread Jason Davidson
whats the error, are there any matching fields for the columns
eventetail.event and event.id?
Jason

"Karl-Heinz Schulz" <[EMAIL PROTECTED]> wrote: 
> 
> Why does this query not work?
> It should only show the eventdetails for the shown event.
> 
> 
> -
> 
>  $event = mysql_query("select id, information from event where id=".$id);  
> ?>
>  
> $eventdetail_query = mysql_query("select titles, informations, file_name
> from eventdetail, event where eventdetail.event = event.id");
> 
> while($eventdetail = mysql_fetch_row($eventdetail_query)){ 
> 
> 
> print(" sans-serif;font-size:12px;\"> href=\"../PDF/$eventdetail[2]\"
> class=\"decisions_links\">".strip_tags(html_decode($eventdetail[0]))." span>");
> print("  sans-serif;font-size:12px;\">".html_decode($eventdetail[1])."");
> 
>  }
> 
>  ?>
> 
> 
> -
> 
> 
> TIA
> 
> Karl-Heinz
> 
> 
> 
> 
> Tracking #: B3BFF38AEF0C854C96E9B501DD35C6C783308CA5
> 
> 

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



Re: [PHP] query question

2003-01-14 Thread Jason Wong
On Wednesday 15 January 2003 01:47, Kelly Meeks wrote:
> I've got an array of values, that I need to query against a database to see
> if any records have any of the values in the array - the array is a list of
> zip codes, and the database contains a list of stores.  Basically i need to
> find what stores have zip codes in the array.
>
> I know that mysql doesn't support subquerys - is there a workaround for
> this kind of scenario?

This is more of a mysql question and should be asked on the php-db list if not 
the mysql list.

What you need is something like:

  "SELECT doo FROM dah WHERE dee IN('val1', 'val2', ..., 'valN'"

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
PEGGY FLEMMING is stealing BASKET BALLS to feed the babies in VERMONT.
*/


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




Re: [PHP] query question

2002-11-14 Thread Steve Buehler
Not sure if I wrote and thanked you or not, but this did the trick.  THANK 
YOU THANK YOU THANK YOU!!!

Steve

At 08:41 PM 11/14/2002 +0100, Marek Kilimajer wrote:
This is checked:

function getstart_end(){
   $result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
   while(($row=mysql_fetch_object($result))){
   if(!$i){
   echo $row->min . " - ";
   $i=$row->min;
   } else {
   list($houre,$minutee,$seconds)=explode(":",$i);
   $minutee=$minutee+5;

if($minutee>=60){$minutee=$minutee-60;$houre=$houre+1;}
   $tmp = 
implode(':',array(str_pad($houre,2,'0',STR_PAD_LEFT) 
,str_pad($minutee,2,'0',STR_PAD_LEFT),'00'));

   if($tmp != $row->min) {  // there is a gap
   //echo $row->min ." != $tmp";
 echo $i ."\n";  // print previous time 
as end
 echo $row->min . " - ";  // print this time 
as new start
   }
   $i = $row->min; // keep this new time for next loop
   }
   //echo $i." - $tmp  --tmp\n";
   //echo $row->min."\n";
   }
   echo $i ."\n";  // print last row
}

Steve Buehler wrote:

Ok.  That output was my fault.  I had an error in one of my other 
functions.  I needed to set $hours to "00" to start with in my 
populatetemptable() function.  Now my output is:
00:05:00 - 00:05:00
00:05:00 - 00:10:00
00:10:00 - 00:15:00
00:10:00 - 00:20:00
00:15:00 - 00:25:00
00:15:00 - 00:30:00

Problem is that it isn't giving me just the start and end times.  I will 
keep working on it.

Thanks
Steve


At 12:48 PM 11/14/2002 -0600, you wrote:

Thanks for the help, but that is not actually producing the desired 
results either.  This returns the following results:
00:00:05 - 00:00:05
00:00:05 - 5
00:00:05 - 10
00:00:05 - 15
00:00:10 - 20
00:00:10 - 25
00:00:10 - 30
00:00:10 - 35
00:00:15 - 40
00:00:15 - 45
00:00:15 - 50
00:00:15 - 55
00:00:20 - 60
00:00:20 - 65

I am not going to post all of them. :)

Here is the code that is now in the getstart_end() function.  I had to 
change the line that you had because the 5 minutes would give an 
error.  I just took out the "minutes" part.
$tmp = $i+5 minutes; // add 5 minutes to $i, 
implement it yourself
function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";
$i=$row->min;
}else{
$tmp = $i+5; // add 5 minutes to $i, implement 
it yourself
if($tmp != $row->min) {  // there is a gap
echo $i ."\n";  // print previous 
time as end
echo $row->min . " - ";  // print this 
time as new start
}
$i = $tmp; // keep this new time for next loop
}
}
echo $row->min ."\n";  // print last row
}

At 07:09 PM 11/14/2002 +0100, you wrote:

Untested, but should work

Steve Buehler wrote:



function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";



   $i=$row->min;



}else{



$tmp = $i + 5 minutes // add 5 minutes to $i, implement it yourself
if($tmp != $row->min) {  // there is a gap
   echo $i ."\n";  // print previous time as end
   echo $row->min . " - ";  // print this time as new start
}
$i = $tmp; // keep this new time for next loop



}
}



echo $row->min ."\n";  // print last row



}



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


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3





--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


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


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3





--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3




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


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3




--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


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

Re: [PHP] query question

2002-11-14 Thread Marek Kilimajer
This is checked:

function getstart_end(){
   $result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
   while(($row=mysql_fetch_object($result))){
   if(!$i){
   echo $row->min . " - ";
   $i=$row->min;
   } else {
   list($houre,$minutee,$seconds)=explode(":",$i);
   $minutee=$minutee+5;
   
if($minutee>=60){$minutee=$minutee-60;$houre=$houre+1;}
   $tmp = 
implode(':',array(str_pad($houre,2,'0',STR_PAD_LEFT) 
,str_pad($minutee,2,'0',STR_PAD_LEFT),'00'));
  
   if($tmp != $row->min) {  // there is a gap
   //echo $row->min ." != $tmp";
 echo $i ."\n";  // print previous time 
as end
 echo $row->min . " - ";  // print this 
time as new start
   }
   $i = $row->min; // keep this new time for next loop
   }
   //echo $i." - $tmp  --tmp\n";
   //echo $row->min."\n";
   }
   echo $i ."\n";  // print last row
}

Steve Buehler wrote:

Ok.  That output was my fault.  I had an error in one of my other 
functions.  I needed to set $hours to "00" to start with in my 
populatetemptable() function.  Now my output is:
00:05:00 - 00:05:00
00:05:00 - 00:10:00
00:10:00 - 00:15:00
00:10:00 - 00:20:00
00:15:00 - 00:25:00
00:15:00 - 00:30:00

Problem is that it isn't giving me just the start and end times.  I 
will keep working on it.

Thanks
Steve


At 12:48 PM 11/14/2002 -0600, you wrote:

Thanks for the help, but that is not actually producing the desired 
results either.  This returns the following results:
00:00:05 - 00:00:05
00:00:05 - 5
00:00:05 - 10
00:00:05 - 15
00:00:10 - 20
00:00:10 - 25
00:00:10 - 30
00:00:10 - 35
00:00:15 - 40
00:00:15 - 45
00:00:15 - 50
00:00:15 - 55
00:00:20 - 60
00:00:20 - 65

I am not going to post all of them. :)

Here is the code that is now in the getstart_end() function.  I had 
to change the line that you had because the 5 minutes would give an 
error.  I just took out the "minutes" part.
$tmp = $i+5 minutes; // add 5 minutes to $i, 
implement it yourself
function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY 
min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";
$i=$row->min;
}else{
$tmp = $i+5; // add 5 minutes to $i, 
implement it yourself
if($tmp != $row->min) {  // there is a gap
echo $i ."\n";  // print previous 
time as end
echo $row->min . " - ";  // print 
this time as new start
}
$i = $tmp; // keep this new time for next loop
}
}
echo $row->min ."\n";  // print last row
}

At 07:09 PM 11/14/2002 +0100, you wrote:

Untested, but should work

Steve Buehler wrote:



function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";



   $i=$row->min;



}else{



$tmp = $i + 5 minutes // add 5 minutes to $i, implement it yourself
if($tmp != $row->min) {  // there is a gap
   echo $i ."\n";  // print previous time as end
   echo $row->min . " - ";  // print this time as new start
}
$i = $tmp; // keep this new time for next loop



}
}



echo $row->min ."\n";  // print last row



}




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


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3





--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


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


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3





--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3





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




Re: [PHP] query question

2002-11-14 Thread Steve Buehler
Ok.  That output was my fault.  I had an error in one of my other 
functions.  I needed to set $hours to "00" to start with in my 
populatetemptable() function.  Now my output is:
00:05:00 - 00:05:00
00:05:00 - 00:10:00
00:10:00 - 00:15:00
00:10:00 - 00:20:00
00:15:00 - 00:25:00
00:15:00 - 00:30:00

Problem is that it isn't giving me just the start and end times.  I will 
keep working on it.

Thanks
Steve


At 12:48 PM 11/14/2002 -0600, you wrote:
Thanks for the help, but that is not actually producing the desired 
results either.  This returns the following results:
00:00:05 - 00:00:05
00:00:05 - 5
00:00:05 - 10
00:00:05 - 15
00:00:10 - 20
00:00:10 - 25
00:00:10 - 30
00:00:10 - 35
00:00:15 - 40
00:00:15 - 45
00:00:15 - 50
00:00:15 - 55
00:00:20 - 60
00:00:20 - 65

I am not going to post all of them. :)

Here is the code that is now in the getstart_end() function.  I had to 
change the line that you had because the 5 minutes would give an error.  I 
just took out the "minutes" part.
$tmp = $i+5 minutes; // add 5 minutes to $i, 
implement it yourself
function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";
$i=$row->min;
}else{
$tmp = $i+5; // add 5 minutes to $i, implement it 
yourself
if($tmp != $row->min) {  // there is a gap
echo $i ."\n";  // print previous 
time as end
echo $row->min . " - ";  // print this 
time as new start
}
$i = $tmp; // keep this new time for next loop
}
}
echo $row->min ."\n";  // print last row
}

At 07:09 PM 11/14/2002 +0100, you wrote:
Untested, but should work

Steve Buehler wrote:



function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";


   $i=$row->min;



}else{


$tmp = $i + 5 minutes // add 5 minutes to $i, implement it yourself
if($tmp != $row->min) {  // there is a gap
   echo $i ."\n";  // print previous time as end
   echo $row->min . " - ";  // print this time as new start
}
$i = $tmp; // keep this new time for next loop



}
}


echo $row->min ."\n";  // print last row



}




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


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3




--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


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


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3




--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


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




Re: [PHP] query question

2002-11-14 Thread Steve Buehler
Thanks for the help, but that is not actually producing the desired results 
either.  This returns the following results:
00:00:05 - 00:00:05
00:00:05 - 5
00:00:05 - 10
00:00:05 - 15
00:00:10 - 20
00:00:10 - 25
00:00:10 - 30
00:00:10 - 35
00:00:15 - 40
00:00:15 - 45
00:00:15 - 50
00:00:15 - 55
00:00:20 - 60
00:00:20 - 65

I am not going to post all of them. :)

Here is the code that is now in the getstart_end() function.  I had to 
change the line that you had because the 5 minutes would give an error.  I 
just took out the "minutes" part.
$tmp = $i+5 minutes; // add 5 minutes to $i, 
implement it yourself
function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";
$i=$row->min;
}else{
$tmp = $i+5; // add 5 minutes to $i, implement it 
yourself
if($tmp != $row->min) {  // there is a gap
echo $i ."\n";  // print previous time 
as end
echo $row->min . " - ";  // print this 
time as new start
}
$i = $tmp; // keep this new time for next loop
}
}
echo $row->min ."\n";  // print last row
}

At 07:09 PM 11/14/2002 +0100, you wrote:
Untested, but should work

Steve Buehler wrote:



function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";


   $i=$row->min;



}else{


$tmp = $i + 5 minutes // add 5 minutes to $i, implement it yourself
if($tmp != $row->min) {  // there is a gap
   echo $i ."\n";  // print previous time as end
   echo $row->min . " - ";  // print this time as new start
}
$i = $tmp; // keep this new time for next loop



}
}


echo $row->min ."\n";  // print last row



}






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


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3




--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


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




Re: [PHP] query question

2002-11-14 Thread Marek Kilimajer
One mistake

Marek Kilimajer wrote:


Untested, but should work

Steve Buehler wrote:



function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";



   $i=$row->min;



}else{



$tmp = $i + 5 minutes // add 5 minutes to $i, implement it yourself
if($tmp != $row->min) {  // there is a gap
   echo $i ."\n";  // print previous time as end
   echo $row->min . " - ";  // print this time as new start
}
// wrong: $i = $tmp; // keep this new time for next loop


$i = $row->min; // this is instead of the previos line





}
}



echo $row->min ."\n";  // print last row



}










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




Re: [PHP] query question

2002-11-14 Thread Marek Kilimajer
Untested, but should work

Steve Buehler wrote:



function getstart_end(){
$result=mysql_query("SELECT * FROM aplayabletimes ORDER BY min");
while(($row=mysql_fetch_object($result))){
if(!$i){
echo $row->min . " - ";


   $i=$row->min;



}else{


$tmp = $i + 5 minutes // add 5 minutes to $i, implement it yourself
if($tmp != $row->min) {  // there is a gap
   echo $i ."\n";  // print previous time as end
   echo $row->min . " - ";  // print this time as new start
}
$i = $tmp; // keep this new time for next loop



}
}


echo $row->min ."\n";  // print last row



}







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




Re: [PHP] query question

2001-05-21 Thread Markus Fischer

On Mon, May 21, 2001 at 10:36:42AM -0500, Jacky wrote : 
> What do I do if i want to move all values stored in one field
> to another field in the same table, from field A to field B?
> Has anyone ever done that? 

As simple as you think it should be

UPDATE table SET column_a = column_b

- Markus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] query question

2001-05-20 Thread Maxim Maletsky

several times:

UPDATE table SET B=A;



Sincerely, 

 Maxim Maletsky
 Founder, Chief Developer
 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-Original Message-
From: Jacky [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 22, 2001 12:37 AM
To: [EMAIL PROTECTED]
Subject: [PHP] query question


Hi all
What do I do if i want to move all values stored in one field to another
field in the same table, from field A to field B? Has anyone ever done that?

Jack
[EMAIL PROTECTED]
"There is nothing more rewarding than reaching the goal you set for
yourself"

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]