show table class

PHOTO EMBED

Fri May 13 2022 01:17:44 GMT+0000 (Coordinated Universal Time)

Saved by @khalidlogi #php

<?php




class Dbtable {


function __construct() {
   // $this->getId();
    add_action( 'admin_notices', array( $this, 'my_update_notice'));
    add_shortcode( 'mydbtable', array( $this, 'showmytable'));

}


public function showmytable() {

    global $wpdb;
    $result = $wpdb->get_results ( "SELECT * FROM khdata_devis  ORDER BY id" );
    ob_start();
//$code = 'Hello World';



    $output = '<table>
    <tr>
      <th> name </th>
      <th>email</th>
      <th>city</th>
    </tr>';

    foreach ( $result as $print )   {
    $output .='<tr>
      <td>"'.$print->city.'"</td>
      <td>"'.$print->email.'"</td>
      <td>21</td>
    </tr>';}

    $output .='</table>';
    
  



return $output;

ob_get_clean();
}


function my_update_notice() {
    global $wpdb;
    ?>
    <div class="updated notice">
        <p><?php _e( "name of Database $wpdb->dbname", 'my_plugin_textdomain' ); ?></p>
    </div>
    <?php
}

}
content_copyCOPY