You might wanna look into a tutorial on how to use a database. The mysql functions section of the php docs have some simple examples to show you things like that.
Basically, you create the query, execute it with something like mysql_query, then get the result with one of the functions to grab data from a result set, like mysql_result(), and pass that var to an echo command. In fact, the first page of the mysql extension has the basics I talk of here:
mysql