Hi,
I am making an online dictionary of golf terms. I have a mySQL db filled with terms and the table structure looks like this:
id: int, primary key, auto_increment
alpha: enum ('select one','a','b','c', ... 'x','y','z') default - select one
term: varchar - 50
definition: varchar - 300
I need help writing my query, however. This is my current code...
<?php
// Login to db
require ("../inc/db.inc.php");
// Connect to db
$my_db = connecting2_db();
// db Query
$sql = "SELECT alpha FROM dictionary ORDER BY id ASC";
// Connect or die and tell us
$result = mysql_query($sql,$my_db) or db_mysql_die();
// While our query is true, do this:
while ($row = mysql_fetch_array($result)){
$letter = $row["alpha"];
echo "<a href='details.php?letter=$letter'>$letter</a> | ";
}
// end SQL session
mysql_close();
?>
It works, except for one tiny problem: For every term it spits out a result. SO, I have this: a,a,a,a,a,a,a,a,a,a,a,a,b,b,b,b,b,b,b,b,b,b,b,c,c,c,c,c,c,c,c,c,c,c and so on...
How can I modify my query so that I just get ONE result, i.e, a,b,c,d,....x,y,z
based on the "alpha" column in my table?
Thanks for any and all help.