The "while" thing
is a type of loop. Every time the condition you give it is true it will execute whatever it is inside. In your code that means it will execute for every single row that came back from the query.
You don't want it to do that. Loops execute multiple times. You don't want it to execute multiple times. Don't use a loop.
It's mostly a matter of removing code. Take a quick look (because that's all it really takes for this) at the documentation link I gave above and decide what parts of the code you should get rid of.
Hint: you still need the bit of code about mysql_fetch_array().
The other thing to remember is that your query will grab every single name. Again, you don't want that. So now you should be asking yourself "Is there a way to make it only get one row?" Yes there is.
As for my question, right now the code will show every single name. You don't want it to show all of them. So which one name do you want it to show? Just some random name? The first one in the table, which is what the SQL above will do? The first name where the data matches some criteria or conditions?