[thelist] PHP/MySQL get unique rows from the table
Matt Warden
mwarden at gmail.com
Mon Jul 25 14:33:36 CDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Nan,
> I only want to show each date once. I googled for this, but am not sure how
> to word it, I used things like --------select unique row----------------but
> didn't get an answer to this question. From what I found, this might involve
> a subquery, but I have never used one and didn't understand the example. Can
A subquery isn't what you want. In fact, if you're using a ratehr old
version of MySQL, it doesn't even support subqueries.
Try this:
select distinct date(start_date)
from yourtable
You probably want to mess with the formatting of the date (for that,
see the date_format function), but this will give you the data you want.
when debugging code by using echo statements, include the line number
> and document, such as:
> echo $foo." on line 1355 of class_events.php";
> This will help you remember where you put it.
PHP has a magic constant called __LINE__ for this purpose (that way
you dont have to keep updating your echo's when you add code anywhere
above it). See
http://us2.php.net/manual/en/language.constants.predefined.php
So, your tip would change to:
echo $foo ." on line ". __LINE__ ." of ". __FILE__;
or, better yet:
function debug($str, $line, $file)
{
echo $str . ' on line '. $line .' of '. $file .'<br />';
}
debug($foo, __LINE__, __FILE__);
Luckily, PHP5 has full stack tracing and exception handling, so this
kind of thing won't be needed.
- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFC5T6PAQ0d4HGyPE8RAtCXAJ4773uZai92Vej0wtCVoVfTkEgCJQCeNaly
AyDtFQq2PA5LCltWg31ceg4=
=lYp3
-----END PGP SIGNATURE-----
More information about the thelist
mailing list