sql query selecting one name no matter how many rows it was mentioned in
- by Baruch
Basically what I'm trying to do is get the information from column x no matter how many times it was mentioned. means that if I have this kind of table:
x | y | z
------+-------+--------
hello | one | bye
hello | two | goodbye
hi | three | see you
so what I'm trying to do is create a query that would get all of the names that are mentions in the x column without duplicates and put it into a select list.
my goal is that I would have a select list with TWO not THREE options, hello and hi
this is what I have so far which isn't working. hope you guys know the answer to that:
function getList(){
$options="<select id='names' style='margin-right:40px;'>";
$c_id = $_SESSION['id'];
$sql="SELECT * FROM names";
$result=mysql_query($sql);
$options.="<option value='blank'>-- Select something --</option>" ;
while ($row=mysql_fetch_array($result)) {
$name=$row["x"];
$options.="<option value='$name'>$name</option>";
}
$options.= "</SELECT>";
return "$options";
}
Sorry for confusing... i edited my source