Re: [PHP] Date Q
On Friday 10 May 2002 13:14, Jason Soza wrote: Thanks for the code, but I already have: $result = mysql_query(SELECT * FROM table); select *, min(datefield) as mindate, max(datefield) as maxdate from table; Should work. It's been my general understanding that querying twice in one script is bad. How do I incorporate your code into my script w/o querying again? Nothing inherently bad about that. After all if you can't do it in one query, what's to stop you using two or more? -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Great American Axiom: Some is good, more is better, too much is just right. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Q
On Friday 10 May 2002 13:02, Jason Soza wrote: If I have a MySQL field full of dates and other info, and my PHP script displays all this, how would I isolate the min and max in the date field? Like I want to print something like: Information, from 01-03-2001 through 01-03-2002 If someone could give me an example or point me to the manual section that describes this, that'd be great. Thanks! select min(datefield) as mindate, max(datefield) as maxdate from table; -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* QOTD: The only easy way to tell a hamster from a gerbil is that the gerbil has more dark meat. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date Q
Thanks for the code, but I already have: $result = mysql_query(SELECT * FROM table); And I use while ($row = mysql_fetch_array($result)) along with extract($row) to get my data. It's been my general understanding that querying twice in one script is bad. How do I incorporate your code into my script w/o querying again? -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 09, 2002 8:59 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Date Q On Friday 10 May 2002 13:02, Jason Soza wrote: If I have a MySQL field full of dates and other info, and my PHP script displays all this, how would I isolate the min and max in the date field? Like I want to print something like: Information, from 01-03-2001 through 01-03-2002 If someone could give me an example or point me to the manual section that describes this, that'd be great. Thanks! select min(datefield) as mindate, max(datefield) as maxdate from table; -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* QOTD: The only easy way to tell a hamster from a gerbil is that the gerbil has more dark meat. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date Q
On Thu, 9 May 2002, Jason Soza wrote: Thanks for the code, but I already have: $result = mysql_query(SELECT * FROM table); And I use while ($row = mysql_fetch_array($result)) along with extract($row) to get my data. It's been my general understanding that querying twice in one script is bad. How do I incorporate your code into my script w/o querying again? What's bad is using more database queries than you need. If you need to know two different things, query twice. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date Q
if you insist in using your existing loop, try this (in pseudo-code) min_date = some really large date (31-Dec-2100 maybe?) max_date = some really small date (01-Jan-1970 maybe?) while (row = fetch(result)) { if (curr_date max_date) max_date = curr_date if (curr_date min_date) min_date = curr_date ... // other code here } same logic can be used for numbers, strings, etc, etc. -Original Message- From: Miguel Cruz [mailto:[EMAIL PROTECTED]] Sent: Friday, May 10, 2002 3:13 PM To: Jason Soza Cc: [EMAIL PROTECTED] Subject: RE: [PHP] Date Q On Thu, 9 May 2002, Jason Soza wrote: Thanks for the code, but I already have: $result = mysql_query(SELECT * FROM table); And I use while ($row = mysql_fetch_array($result)) along with extract($row) to get my data. It's been my general understanding that querying twice in one script is bad. How do I incorporate your code into my script w/o querying again? What's bad is using more database queries than you need. If you need to know two different things, query twice. miguel -- 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