(For this answer, I will use the mysqli extension -- you could also want to use PDO ;; note that the mysql extension is old and should not be used for new applications)
You first have to connect to your database, using mysqli_connect
(And you should test if the connection worked, with mysqli_connect_errno
and/or mysqli_connect_error
).
Then, you'll have to specifiy with which database you want to work, with mysqli_select_db
.
Now, you can send an SQL query that will select all data from your users, with mysqli_query
(And you can check for errors with mysqli_error
and/or mysqli_errno
).
That SQL query will most likely look like something like this :
select id, name
from your_user_table
order by name
And, now, you can fetch the data, using something like mysqli_fetch_assoc
-- or some other function that works the same way, but can fetch data in some other form.
Once you have fetched your data, you can use them -- for instance, for display.
Read the pages of the manual I linked to : many of them include examples, that will allow you to learn more, especially about the way those functions should be used ;-)
For instance, there is a complete example on the page of mysqli_fetch_assoc
, that does exactly what you want -- with countries insteand of users, but the idea is quite the same ^^