RE: [PHP-DB] Newbie wants column data without duplication

From: Date: Sun, 12 Aug 2001 19:08:24 +0000
Subject: RE: [PHP-DB] Newbie wants column data without duplication
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11272@lists.php.net to get a copy of this message
If you only want the different (tutor_group)s to be listed, then just do this: I also believe (but am not sure) you could have used GROUP BY instead of ORDER BY in your original query to fix the problem. echo "Click on a Tutor group to see it's members<br><br>"; $result = mysql_query("SELECT DISTINCT tutor_group FROM pupil_details ORDER BY tutor_group ASC",$db); while($myrow = mysql_fetch_array($result)) { printf("<a href=?tutor_group=$myrow[tutor_group]>$myrow[tutor_group]</a><br>\n", $PHP_SELF, $myrow[tutor_group]); } -----Original Message----- From: dagza@email.com [mailto:dagza@email.com] Sent: Sunday, August 12, 2001 2:59 PM To: php-db@lists.php.net Subject: [PHP-DB] Newbie wants column data without duplication I have only been doing this for a week so be gentle with me :) I have set up a database (in Mysql) which contains details about my sudents. I am able to produce a list of tutor groups so when the user clicks on a tutor group name he/she is taken to a list of all of those students in that tutor group. The problem is the tutor group name is duplicated depending upon how many members it contains. IE If 12 people belong to 7DS then 7DS appears on the list 12 times. Once would be better. Any advice, bits of code or URLs that would contain the answer would be more thatn welcome. My PHP code follows (please don't laugh at it!) echo "Click on a Tutor group to see it's members<br><br>"; $result = mysql_query("SELECT * FROM pupil_details ORDER BY tutor_group",$db); if ($myrow = mysql_fetch_array($result)) { do { printf("<a href=?tutor_group=$myrow[tutor_group]>$myrow[tutor_group]</a><br>\n", $PHP_SELF, $myrow[tutor_group]); } while ($myrow = mysql_fetch_array($result)); } Thanks for your time Darren -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#11272) next »