php - 将 MySQL 查询的结果动态显示到 HTML 页面中

标签 php html mysql sql yii

我使用 YII 框架,我想将 MySQL 查询的结果放在 index.php 的表中。

MySQL 查询已经很好了:

SELECT categories.name,
    systemes.name,
    systemes.etat_de_base,
    maintenances.name,
    maintenances.date,
    maintenances.duree 
FROM systemes_maintenances 
LEFT JOIN systemes 
ON systemes_maintenances.id_systemes = systemes.id_systemes 
LEFT JOIN categories 
ON systemes.id_categories = categories.id_categories 
LEFT JOIN maintenances 
ON systemes_maintenances.id_maintenances = maintenances.id_maintenances;

我的 PHP 页面现在看起来像这样:

<?php
/* @var $this SiteController */

$this->pageTitle=Yii::app()->name;
?>

<!--<h1>Welcome to <i><?php echo CHtml::encode(Yii::app()->name); ?></i></h1>

<p>Congratulations! You have successfully created your Yii application.</p>

<p>You may change the content of this page by modifying the following two files:</p>
<ul>
    <li>View file: <code><?php echo __FILE__; ?></code></li>
    <li>Layout file: <code><?php echo $this->getLayoutFile('main'); ?></code></li>
</ul>

<p>For more details on how to further develop this application, please read
the <a href="http://www.yiiframework.com/doc/">documentation</a>.
Feel free to ask in the <a href="http://www.yiiframework.com/forum/">forum</a>,
should you have any questions.</p>-->

<table>
    <caption>&Eacute;tat des systèmes</caption>
    <tr>
    <th>Cat&eacute;gorie</th>
    <th>Nom</th>
    <th>&Eacute;tat actuel</th>
    <th>Maintenance prévue</th>
    <th>Début de l'incident</th>
    </tr>
    <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>



</table>

我想在空<td> </ td>中显示结果.

有谁知道不用 jQuery 怎么办?

最佳答案

由于您使用的是 Yii 框架,因此您可以使用 CGridView 组件。这提供了一组不错的功能,例如排序、分页和过滤。 检查以下链接以获取示例用法。 http://www.yiiplayground.com/index.php?r=UiModule/dataview/gridView

关于php - 将 MySQL 查询的结果动态显示到 HTML 页面中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22372478/

相关文章:

php - Cron 执行的 Bash 脚本中的 PHP 脚本序列未运行

javascript - 父div之外的类的Jquery最接近方法

php - MySQL数据 - 统计同时通话的次数

php - 将数据从一个表插入到另一个php sql

mysql - 如何显示引用主表上的两个外部 ID 键的表的字符串值

PhpStorm 对 JSON 函数的警告

php - 使用特定的 php 日期时间戳从今天获取值

php - 提取 Twitter 个人资料图像时的类 ="disconnect-collapsed"

javascript - 使用触发器 "click"下载附加到 <a> 的多个 CSV 文件不起作用

html - 将按钮放在内联 block div 旁边