If all you want is a unique list of "adr_one_region" codes, then use the 
DISTINCT keyword in your SQL:

SELECT DISTINCT adr_one_region FROM egw_addressbook WHERE cat_id='8' ORDER BY 


= = = Original message = = =

Hello everyone....

I'm back working on the website again... I'm having lots of fun.
I have a sql query that looks at one field in a database. (result2 query)
Then i have mysql_fetch_array statement.

I then use this array to print links on the page.
Works fine except I don't want duplicate links.

It creates links for the states.  If we have four customers from Pennsylvania.  
This current process gives me four different "PA" links on my page.  

I need a statement that says...if its already printed...don't print it...


Here is my code:




$db = mysql_connect("HOST", "USERNAME", "PASSWORD");


if ($_GET[area]=="") 

$master = mysql_query("SELECT * FROM egw_addressbook

WHERE cat_id='8' ORDER BY org_name", $db);


$master = mysql_query("SELECT * FROM egw_addressbook

WHERE cat_id='8' and adr_one_region='$_GET[area]' ORDER BY org_name", $db);

$result2 = mysql_query("SELECT adr_one_region FROM egw_addressbook

WHERE cat_id='8' ORDER BY adr_one_region", $db);

if ($area = mysql_fetch_array($result2)) 

echo "Sort by State: ";


echo "<a 

echo " - ";

 while ($area = mysql_fetch_array($result2));

echo "<a href='index.php?area='>ALL</a>\n";


echo "ERROR";

if ($myrow = mysql_fetch_array($master)) 

echo "<CENTER>\n";

echo "<table border=0>\n";

echo "<img src=file.jpg width='611' height='136'>\n";

echo "<BR>\n";

echo "<BR>\n";


printf("<tr> <td></td><td><b>%s</b></td><td></td><td></td><td>%s</td></tr>\n", 
$myrow["org_name"], $myrow["fn"]); 

printf("<tr> <td></td><td>%s</td><td></td><td></td><td>%s</td></tr>\n", 
$myrow["adr_one_street"], $myrow["tel_work"]);

printf("<tr> <td></td><td>%s, %s 
$myrow["adr_one_locality"], $myrow["adr_one_region"], 

 while ($myrow = mysql_fetch_array($master));

echo "</table>\n";

echo "</CENTER>\n";


echo "Sorry, no records were found!"; 




Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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

Reply via email to