Okay...There are rows and columns in your database. The elements like id,name,position, and email are columns. The individual entries for each person are rows. Think of it as a spreadsheet of sorts...
$query = "...";
This defines your query that you're sending to the database. Your query is saying select every column (SELECT *) from the staff table and put them in order by the id number. The order defaults to ascending (ASC). You can use DESC for decending. Since there is no WHERE clause on your query, every row is selected.
$result = mysql_query($query);
This actually sends the query to the database. $result is not the data returned from the query. It's a pointer of sorts that you use to get the data or number or rows returned.
while($r = mysql_fetch_array($result))
This creates your loop. mysql_fetch_array($result) goes and gets the first row from the result set returned by your query. Each time you call mysql_fetch_array($result), it'll go to the next row. The row is assigned to the array $r. The first column in your database is assigned to $row[0], the second to $row[1], etc... You can also use the name of the column as the key in your array. Assuming you have an id,name,position, and email column in your table, and they are in that order...
$row[0] -> $row[id] -> id column
$row[1] -> $row[name] -> name column
$row[2] -> $row[position] -> position column
$row[3] -> $row[email] -> email column
Once the last row is fetched, mysql_fetch_array() will return false, so that will end your while loop.
Hope that helped. Now go read the rest of the manual.
---John Holmes...