How to display specific data from custom database table in WordPress
-
Hi,
I have created a Custom Post Type by name “Project” and a Custom Database table namedwp_project_db
for it.The
wp_project_db
consist of 4 Columns –order_id
,user_id
,project_id
andreward_amount
.My question is that I want to fetch & display the data from the table mentioned above on the project page.
I used following code to display:
<?php global $wpdb; $customers = $wpdb->get_results("SELECT * FROM wp_project_db"); ?> <table class="table table-hover"> <?php foreach($customers as $customer){ ?> <tr> <td><center><?php echo $customer->order_id; ?></center></td> <td><center><?php echo $customer->user_id; ?></center></td> <td><center><?php echo $customer->project_id; ?></center></td> <td><center><?php echo $customer->reward_amount; ?></center></td> </tr> <?php } ?> </table>
The problem is that the above code displays whole data from the database table. I want to display specific data relating to a project on that particular project page.
Plz help, Thanks.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to display specific data from custom database table in WordPress’ is closed to new replies.