I have look all day the whole internet and didn't find fetching data in tabular format. I have my short code and everything is ready, I have this code which is display data but not in good format as you can see in the screen shot I want data like this in WordPress page.
<?php
?>
<table border="1">
<tr>
<th>Char Item</th>
<th>Item Id</th>
<th>Item Description</th>
</tr>
<?php
global $wpdb;
$result = $wpdb->get_results ( "SELECT * FROM wp_orderlist" );
foreach ( $result as $print ) {
echo '<td>'. $print->char_item.'</td>';
echo '<td>'. $print->item_id.'</td>';
echo '<td>'. $print->Item_Description.'</td>';
}
?>
</table>
You forget to add tr tag. Try this:
echo '<tr>';
foreach ( $result as $print ) {
echo '<td>'. $print->char_item.'</td>';
echo '<td>'. $print->item_id.'</td>';
echo '<td>'. $print->Item_Description.'</td>';
}
echo '</tr>';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.