[PHP-DB] Help! With MySQL CASE problem

2006-10-15 Thread Andrew Darby
Hello, all. I'm having a problem with a php/mysql app which is probably in the SQL, so please don't get angry at me. Basically, I have a CASE statement that works on my localhost, but doesn't seem to get recognised on the production server (i'm running php/mysql 5.x on my localhost, 4.x of both

[PHP-DB] Re: Help! With MySQL CASE problem

2006-10-15 Thread Andrew Darby
Good people of php-db, I think I have this solved. For those keeping score, repeating the CASE condition in the ORDER BY seems to work, i.e., SELECT DISTINCT e.exhibition_id, e.title, e.begin_date, CASE 'heading' WHEN UNIX_TIMESTAMP( ) >= e.begin_date THEN 'Coming Up' ELSE 'Now Showing' END 'hea

[PHP-DB] urgent: Trying to get COUNT for fairly elaborate query

2006-10-15 Thread sneakyimp
See this query? I need a separate query that will return ONLY the total record count that it would come up with. I've tried replacing the select part with COUNT() but I still get a series of records in my return result. I just need ONE return value -- the total COUNT of rows returned by this qu

Re: [PHP-DB] urgent: Trying to get COUNT for fairly elaborate query

2006-10-15 Thread Chris
sneakyimp wrote: See this query? I need a separate query that will return ONLY the total record count that it would come up with. I've tried replacing the select part with COUNT() but I still get a series of records in my return result. I just need ONE return value -- the total COUNT of rows r

Re: [PHP-DB] Re: Help! With MySQL CASE problem

2006-10-15 Thread Chris
Andrew Darby wrote: Good people of php-db, I think I have this solved. For those keeping score, repeating the CASE condition in the ORDER BY seems to work, i.e., SELECT DISTINCT e.exhibition_id, e.title, e.begin_date, CASE 'heading' WHEN UNIX_TIMESTAMP( ) >= e.begin_date THEN 'Coming Up' ELSE '

Re: [PHP-DB] urgent: Trying to get COUNT for fairly elaborate query

2006-10-15 Thread sneakyimp
chris smith-9 wrote: > > Doing this is actually rather easy. > > Replace this: > > SELECT e.id, e.title, e.subheading, eta.start_timestamp, > eta.end_timestamp, e.zip, e.bold, e.outline, e.color, e.subheading, > COUNT(esa.id) AS subcat_count > > With: > > SELECT COUNT(e.id) AS count > >

Re: [PHP-DB] urgent: Trying to get COUNT for fairly elaborate query

2006-10-15 Thread Chris
sneakyimp wrote: chris smith-9 wrote: Doing this is actually rather easy. Replace this: SELECT e.id, e.title, e.subheading, eta.start_timestamp, eta.end_timestamp, e.zip, e.bold, e.outline, e.color, e.subheading, COUNT(esa.id) AS subcat_count With: SELECT COUNT(e.id) AS count Or am I

Re: [PHP-DB] urgent: Trying to get COUNT for fairly elaborate query

2006-10-15 Thread sneakyimp
chris smith-9 wrote: > > Ah - that would be the group by doing that. > > Removing those: > > GROUP BY eta.id ORDER BY subcat_count DESC, eta.id > > Does that get you what you want? > > If it gives you one result - make sure it's right. Change a few id's, > make sure they match up to what y

Re: [PHP-DB] urgent: Trying to get COUNT for fairly elaborate query

2006-10-15 Thread Chris
sneakyimp wrote: chris smith-9 wrote: Ah - that would be the group by doing that. Removing those: GROUP BY eta.id ORDER BY subcat_count DESC, eta.id Does that get you what you want? If it gives you one result - make sure it's right. Change a few id's, make sure they match up to what your

Re: [PHP-DB] urgent: Trying to get COUNT for fairly elaborate query

2006-10-15 Thread sneakyimp
The original query results (minus most of the fields but including the COUNT(esa.id) part) would look something like this: id title subcat_count 60 Another Halloween Party 4 50 Satan's Midnight October Bash 1 61 Halloween IPN Testing party 1 19 test 1 64 I happen more than once today 1 6

[PHP-DB] month

2006-10-15 Thread Ron Piggott (PHP)
Is there a slick and easy way to convert January to 01 ? (and February to 02, etc) Ron

Re: [PHP-DB] month

2006-10-15 Thread Chris
Ron Piggott (PHP) wrote: Is there a slick and easy way to convert January to 01 ? (and February to 02, etc) Ron You asked this on the general list and got a few responses. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubsc

Re: [PHP-DB] month

2006-10-15 Thread Ron Piggott (PHP)
I have completely missed it and need to try again.

Re: [PHP-DB] month

2006-10-15 Thread J R
search the archive. On 10/16/06, Ron Piggott (PHP) <[EMAIL PROTECTED]> wrote: I have completely missed it and need to try again. -- GMail Rocks!!!

RE: [PHP-DB] month

2006-10-15 Thread Bastien Koert
use an array $months = array('01'=>'January','02'=>'February'...); $thisMonths = array_flip($months); $month = $thisMonths['January']; echo $month; though its easier to just create the array the other way and the just reference it $months = array(''January''=>'01','February'=>'02...'); $mo