Really need help with a php coded mysql query.

Basically like this---
Link = localhost, user, password
query = SELECT * FROM posts

Now I need to results to go into an array or something so I can use a foreach to print:
<tr>
<td>$displayname says, $post</td>
</tr>

How would the foreach look? Really stuck...