Hi would some one be kind enough to explain how i would display the data from one field in the database but not show duplicate entries?
<?
include_once 'inc/chickensoup.inc';
@mysql_connect($host,$user,$password) or die ("Unable to connect to server!");
@mysql_select_db($database) or die ("Unable to connect to database, please try later!");
$query="SELECT * FROM useful_address ORDER BY cat";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<ol start="1">
<?php
$i=1;
while ($i < $num) {
$cat=mysql_result($result,$i,"cat");
?>
<li><a href="addresses.php?cat=<? echo $cat;?>"><? echo $cat;?></a></li>
<?
$i++;
}
?>
</ol>
The above is what I have been using to display different tables in the database (with the exception of having changed the query to ORDER BY) and I realize that it's the loop that is causing all the duplicates to show, but I'm so new to php that I'm not sure how to edit it so that only one of each category will show up.
The reason for this is that I want to be able to display a list of the categories, each category will then be a link to display the full data for that category (this part I don't have any problems with).
I would be so grateful if someone could explain how I should edit the above, or if you know of a link I could use to get more information.
I've done a search using "duplicate entries mysql" as the criteria, but haven't been able to find any examples of how to do this.
Many thanks in advance,
Linda