Forum Moderators: coopster
Let me start with a bit of a preface of my problem here.
I have a site with a decent amount of data stored into a mysql backend.
I have built a search engine to be able to search this information and be able to show it to the customer, but I have been forced to hand code all of the different options.
I would like to be able to code it to populate the information from the fields that are already in the database. I can code this part ok, the problem I am having is that I am getting all the duplicate information.
I want to know how to just include the first of every duplicate. So for example if I wanted to do a search for John and I had like 10 different Johns in the db the search list would only show John or Jon, not John 10 times in a row.
Any help would be greatly appreciated!
----
As far as your curiosities, I come from a programming background, but have self-taught myself MySQL and PHP.
If the entries are the same you can SELECT DISTINCT which will not have duplicates.
Refer to the select syntax here: [dev.mysql.com...]
$query = "select distinct name from db where valid='yes'";
$result = mysql_query($query);
while($row=mysql_fech_array($result, MYSQL_NUM))
{
$output .= "<option value='" . $row[0] . "'>" . $row[0] . "</option>";
}
Thanks again for the input.
--- edit: missed a close quote