gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 07:37:13 26 4
gpt4 key购买 nike

我使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com