[PHP-DB] SQL query prob

2002-07-17 Thread Russ

I'll try that one again

I have a query:
$sql = SELECT * FROM contacts ORDER BY ContactType;

There are two types of contacts: 

* Commissioners
* Staff

As they are ordered by the ContactType then 'Commissioners' are
displayed first followed by 'Staff'.
  
I'd like to be able to display a heading on the page at the point of the
FIRST instance of 'Commissioners' and at the FIRST instance of 'Staff'.
As I'm using a while loop in my PHP script then at present such a
heading would be displayed atop *each* item would it not?

I think I need to use some kind of COUNT() but am unsure how to deploy
it.
Can anyone help me out?

Cheers.
Russ

Mr Russ Michell
Web Applications Developer

Itomic.com 
Email: [EMAIL PROTECTED] 
Tel: +61 (0)8 9321 3844 
Fax: +61 (0)8 6210 1364 
Post: PO Box 228, Innaloo, WA 6918, Australia 
Street: Suite 24, 158 William St, Perth, WA 6000, Australia

No proof of existence is not proof of non-existence.
(Physicist: Stanton T. Friedman on Debunking Ufology)


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




RE: [PHP-DB] SQL query prob

2002-07-17 Thread Cal Evans

It would unless you told it not to. Set a flag
$lastContactType='';

Then on the first page you display something where then display it and then
if ($lastContactType != $row['contactType']){
echo $row['contactType'];
$lastContactType=$row['contactType'];
} // if ($lastContactType != $row['contactType'])


When contactType changes again, you'll display it again and reset the flag
again.

HTH,
=C=


*
* Cal Evans
* The Virtual CIO
* http://www.calevans.com
*


-Original Message-
From: Russ [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 17, 2002 8:44 PM
To: PHP DB Mailing List (E-mail)
Subject: [PHP-DB] SQL query prob


I'll try that one again

I have a query:
$sql = SELECT * FROM contacts ORDER BY ContactType;

There are two types of contacts:

* Commissioners
* Staff

As they are ordered by the ContactType then 'Commissioners' are
displayed first followed by 'Staff'.

I'd like to be able to display a heading on the page at the point of the
FIRST instance of 'Commissioners' and at the FIRST instance of 'Staff'.
As I'm using a while loop in my PHP script then at present such a
heading would be displayed atop *each* item would it not?

I think I need to use some kind of COUNT() but am unsure how to deploy
it.
Can anyone help me out?

Cheers.
Russ

Mr Russ Michell
Web Applications Developer

Itomic.com
Email: [EMAIL PROTECTED]
Tel: +61 (0)8 9321 3844
Fax: +61 (0)8 6210 1364
Post: PO Box 228, Innaloo, WA 6918, Australia
Street: Suite 24, 158 William St, Perth, WA 6000, Australia

No proof of existence is not proof of non-existence.
(Physicist: Stanton T. Friedman on Debunking Ufology)


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



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