Hi Everyone, Got a really strange problem with a mysql select query not displaying results in select dropdown.

I have a small db table id,position,name and I am trying to display just the names where the position is GK

Here is my query

$result_dglass = mysql_query("select name from team where position like '%gk%' order by id Asc");

The strange thing is, It looks like the drop down is being populated with the correct amount of results, But the text is not being displayed.

I have tried populating the same dropdown with a different query to a different table and that populates perfectly.
and ideas where I am going wrong ?

Thanks in advance

2 Years
Discussion Span
Last Post by nobita2811

how do you populate the dropdown?

    <option><?php echo $row['name'];?></option>

Otherwise, you want to add it on your query e.g. id,

    $result_dglass = mysql_query("select name, id from team where position like '%gk%' order by id Asc");

then you can have at least another item on your option

<option value="<?php echo $row['id'];?>" ><?php echo $row['name'];?></option>

Hi, I totally forgot to change the

<option><?php echo $row['name'];?></option>

Thanks, Thats brings back all the names, But when I add

where position like '%gk%'

I got no results again?


you need to add position like so

 $result_dglass = mysql_query("select name, id, position from team where position like '%gk%' order by id Asc");

try again with:

select `name` from `team` where `position` like '%gk%' order by `id` Asc
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.