MySQL Select within WP Page template

@Adrian,

You don’t really need to assign anything to variables. You already have the information, you just need to loop through it and add the required HTML as you wish.

If you actually want to use a table you can do something similar to:

<table>
<?php 
$myrows = $wpdb->get_results( "SELECT first_name, surname FROM members" );
foreach ( $myrows as $row ) {
echo "<tr><td>" . $row->first_name . "</td><td>" . $row->surname . "</td></tr>";
}
?>
</table>

That will start the table, loop through each result (adding as a table row with two columns) and then closing the table.

The same can be done with a list:

<ul>
<?php 
$myrows = $wpdb->get_results( "SELECT first_name, surname FROM members" );
foreach ( $myrows as $row ) {
echo "<li>" . $row->first_name . " " . $row->surname . "</li>";
}
?>
</ul>

Just make sure you keep the UL or the TABLE outside the loop.