DISTINCT fields

admin

Administrator
Staff member
I was wondering how I might fix this problem:

currently I have a table in a MySQL database that has several fields, here is the dump:

CREATE TABLE ski_packages (
ski_id int(3) NOT NULL auto_increment,
ski_site varchar(64) NOT NULL,
ski_room varchar(64) NOT NULL,
ski_desc text NOT NULL,
ski_prices decimal(8,2) DEFAULT '0.00' NOT NULL,
ski_season varchar(64) NOT NULL,
PRIMARY KEY (ski_id)
);

-----
I am querying the database as such:


<?


$query = "SELECT * FROM ski_packages WHERE ski_site = 'SKI_SITE'";
$mysql_result = mysql_query($query);
while($row = mysql_fetch_array($mysql_result)){
$ski_id = $row[0];
$ski_site = $row[1];
$ski_room = $row[2];
$ski_desc = $row[3];
$ski_prices = $row[4];
$ski_season = $row[5];



echo "<option value=http://www.phpbuilder.com/board/archive/index.php/\"$ski_room\">$ski_room</option>";
}

printf("</select>\n");
printf("<input type=\"hidden\" name=\"ski_site\" value=\"$ski_site\">\n");
printf("<input type=\"Submit\" name=\"ski_submit\" value=\"Send\">\n");

echo"</form>";
?>

-------
This creates a drop down list and populates it. My problem is that since it is displaying the $ski_room data if there is a duplicate entry it shows all of them. I want it to choose only choices that are distinct. In other words; If I have'SkiSite1', 'SkiSite2' etc... but if the next entry is also 'SkiSite2' then my list displays both. This is not what I want... I only want 'SkiSite2' to show up once in the drop down list.

Hope this was clear and thank-you
 
Back
Top