HOME / BLOG / BLOG-POST

How to display specific data from custom database table in WordPress?

Display specific data from custom database table in WordPress

<table border="2">
<tr>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>Phone</th>
<th>Message</th>
</tr>
<?php
global $wpdb;
$table_name = $wpdb->prefix . "my_plugintable";
$result = $wpdb->get_results ( "SELECT * FROM $table_name" );
foreach ( $result as $print ) {
?>
<tr>
<td><?php echo $print->id;?></td>
<td><?php echo $print->firstname;?></td>
<td><?php echo $print->lastname;?></td>
<td><?php echo $print->email;?></td>
<td><?php echo $print->phone;?></td>
<td><?php echo $print->message;?></td>
</tr>
<?php
}
?>
</table>

 


about authors

Sandip Das

Web Developer

Once a legend said “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler.



POST COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *