将html h1连接到数据库列值

问题描述 投票:-1回答:1

我创建了一个数据库,最后将其连接到我的php网站,但是我有一个区域,其中有文本,这是今天的新闻,我希望能够在h1中显示数据库中的文本

我没有找到方法,有人可以帮助我还是给我一个跟踪的方法

<h1>  <?php
  $file = file("adminpanel/info1title.txt");
    foreach($file as $text) {
      echo $text."<br />";
    }
    ?>
  </h1>

这是我所做的,现在它已连接到文件txt,但是有点便宜,现在我想将其连接到数据库列而不是txt文件

php html database
1个回答
0
投票

h1标题标签应附加在echo语句内,而不是php标签之外。

<?php
  $file = file("adminpanel/info1title.txt");
    foreach($file as $text) {
      echo "<h1>" . $text . "</h1><br>";
    }
?>

0
投票

h1标题标签应附加在echo语句内,而不是php标签之外。

<?php
  $file = file("adminpanel/info1title.txt");
    foreach($file as $text) {
      echo "<h1>" . $text . "</h1><br>";
    }
?>
© www.soinside.com 2019 - 2024. All rights reserved.