首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Drupal8新手入门-在页面内容中使用PHP脚本?

Drupal8新手入门-在页面内容中使用PHP脚本?
EN

Stack Overflow用户
提问于 2019-08-27 16:13:09
回答 1查看 140关注 0票数 0

我有一个连接到MySQL数据库的PHP脚本,并从其中提取信息并将其加载到一个可搜索的表中。如果我加载localhost/testphp.php

一切都很好,一切都很好,但我正在尝试将该页面添加到Drupal8中,但我不确定最好的方法。因为当您在Drupal中创建页面时,它似乎不会运行PHP代码。

下面基本上就是我写的东西。

代码语言:javascript
复制
<table id="myTable">
<thead>
  <tr class="header">
    <th style="width:20%;">Drawing ID</th>
    <th style="width:25%;">Sheet Number</th>
    <th style="width:25%;">Revision</th>
    <th style="width:30%;">First Title Line</th>
    <th style="width:30%;">Second Title Line</th>
    <th style="width:30%;">Third Title Line</th>
    <th style="width:30%;">Fourth Title Line</th>
    <th style="width:30%;">Notes</th>
    </tr>
 </thead> 
 <tbody>
<?php

require '../scripts/connect.php';

$sql = "SELECT * FROM drawing_data";
$result = mysqli_query($dbc, $sql) or die("Bad Query: $sql");

while($row = mysqli_fetch_assoc($result)) {
    echo"<tr><td>{$row['First Part']} / {$row['Second Part']} / {$row['Third Part']} / {$row['Fourth Part']} </td><td>{$row['Sheet Number']}</td><td>{$row['Revision']}</td><td>{$row['First Title Line']}</td><td>{$row['Second Title Line']}</td><td>{$row['Third Title Line']}</td><td>{$row['Fourth Title Line']}</td><td>{$row['Notes']}</td><tr>";
}

?>
</tbody>
</table>
</div>

我刚开始使用Durpal,已经很长时间没有做过web dev类型的东西了。所以可能有更好的方法来解决它,但我觉得我不够聪明,不能自己解决这个问题。

EN

回答 1

Stack Overflow用户

发布于 2019-08-28 19:34:41

搜索如何在Drupal8中创建自定义页面。网上有很多关于这个主题的教程。也就是说。

https://www.drupal.org/docs/8/creating-custom-modules/create-a-custom-page

。。或者..。

https://www.anubavam.com/blogs/how-to-develop-custom-page-on-drupal-8

或者找一些其他的,也许是视频教程。

基本上,您必须定义一个路由,然后为该路由调用控制器。使用drupal的主题系统并将html放入twig模板中也会很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57670359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档