Sql result loop problem !

From: Date: Fri, 18 May 2001 14:32:51 +0000
Subject: Sql result loop problem !
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-9439@lists.php.net to get a copy of this message
I know someone can help ! Following sql SELECT DISTINCT s_news_text,s_bereich_name,s_users_real_name,s_bereich_id FROM s_news,s_users,s_bereich WHERE (s_news_user_id = s_users_user_id) AND (s_news_bereich_id = s_bereich_id) AND (s_news_sent ='0') ORDER BY s_bereich_name while ($p = mysql_fetch_array($result1)) { $msg .= $p["s_bereich_name"]; $msg .= $p["s_news_text"]; $msg .= $p["s_users_real_name"]; The result gets passed on and mailed ! The question is I have 6 bereichs(areas) identified with a number = s_bereich_id and I only want the name of the area to appear once. To try and explain a bit better, there are 3 tables - users - where the names and mail addresses come from bereich - where the areas name and numbers are and news - where the actual messages are, and info for which area and from who The mail should then look like Area 1 news name news2 name news3 name Area 2 news name etc at the moment I can only work out how to get Area 1 news name Area 1 news name Anyhelp appreciated ! Thanks in advance Keith

« previous php.db (#9439) next »