有人可以帮助我,如何编写逻辑来将数据从我的数据库打印到 table?table border=1trthFirstname/ththLastname/ththPoints/th/trtr?phpglobal $wpdb;$result = $wpdb-get_results ( SELECT...
有人可以帮助我,如何编写逻辑来将数据从我的数据库打印到< 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>
我知道这是如此基本,但我真的很难让这项工作.
解决方法:
试试这个:
<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 }
?>
织梦狗教程
本文标题为:php – 使用wordpress $wpdb显示数据库内部的数据
基础教程推荐
猜你喜欢
- dedecms织梦复制https链接网站图片无法本地化的解决办法 2022-06-23
- 织梦采集标题不完整的解决方法,修改标题长度 2022-07-14
- 织梦dedecms后台添加变量提示Request var not allow 2023-07-08
- PbootCMS伪静态配置教程以及各web容器配置规则 2023-07-08
- Thinkphp5结合layer弹窗定制操作结果页面 2022-08-16
- 织梦dedecms不显示未审核tag标签文档的的方法 2022-11-04
- PbootCMS的阿里云短信发送类 2023-07-09
- pbootcms文章插入图片不固定宽高的办法 2023-07-08
- dedecms织梦全局变量调用方法总结 2023-07-08
- PbootCMS调用全站所有栏目最新文章的写法 2023-07-09