使用wordpress $ wpdb显示<table>中数据库中的数据

bob*_*nes 3 php wordpress html-table

有人可以帮助我,如何编写逻辑来将我的数据库中的数据打印成<table>

<table border="1">
    <tr>
     <th>Firstname</th>
     <th>Lastname</th>
     <th>Points</th>
    </tr>
    <tr>
      <?php
        global $wpdb;
        $result = $wpdb->get_results ( "SELECT * FROM myTable" );
        foreach ( $result as $print )   {
            echo '<td>' $print->firstname.'</td>';
            }
      ?>
    </tr>               
</table>
Run Code Online (Sandbox Code Playgroud)

表

我知道这是如此基本,但我真的很难让这项工作.

DS9*_*DS9 11

试试这个:

<table border="1">
<tr>
 <th>Firstname</th>
 <th>Lastname</th>
 <th>Points</th>
</tr>
  <?php
    global $wpdb;
    $result = $wpdb->get_results ( "SELECT * FROM myTable" );
    foreach ( $result as $print )   {
    ?>
    <tr>
    <td><?php echo $print->firstname;?></td>
    </tr>
        <?php }
  ?>              
Run Code Online (Sandbox Code Playgroud)