Hi all,
How can you get one value when there are many that are the same?
For instance, i have a php page that when a user clicks on a letter (for example "A") a list of suburbs are displayed.
What i need to know is that if there are several suburbs that are exactly the same i only want one of the suburbs name to show.
This is my script so far:
<?
include ("include/header.inc.php");
include ("include/dbconnect.php");
$result = mysql_query("SELECT * FROM $table WHERE LEFT(suburb,1) = '$alphabet' ORDER BY suburb",$db);
echo "<table cellpadding=2 cellspacing=1 border=0>";
$resultsnumber = mysql_numrows($result);
$alternate = "2";
echo "Number of results: $resultsnumber";
while ($row = mysql_fetch_array($result)) {
$id = $row["CatID"];
//$firstname = $row["CatParent"];
$lastname = $row["suburb"];
if ($alternate == "1") {
$color = "#ffffff";
$alternate = "2";
}
else {
$color = "#efefef";
$alternate = "1";
}
echo "<tr bgcolor=$color><td>$lastname </td><td><a href='view.php?id=$id'>see details</a></td><td><a href='edit.php?id=$id'>edit record</a></td><td><a href='delete.php?id=$id' onClick=\"return confirm('Are you sure?')\">delete record</a></td></tr>";
}
if ($resultsnumber == "0") {
echo "There are <b>no</b> categories under this letter";
}
echo "</table>";
?>
Any ideas?
Cheers,
maccam