如何更改 php 文件中段落的外观
P粉596191963
P粉596191963 2024-01-29 15:04:44
0
1
439

我尝试将文件制作为html文件,或者直接将 <link rel="stylesheet" type="text/css" href="mystyle.css"> 立即放入,但它不起作用。 我希望能够更改 pharagraph producten 字体大小。

这是我到目前为止的代码(关于最后一部分())

<?php
  include('DatabaseConnector.php');
  $database = new DatabaseConnector("test", "root", "");
  <link rel="stylesheet" type="text/css" href="mystyle.css">

    $email = $database->selectValue("SELECT emailadres FROM klant WHERE naam = 'Bibiche' AND achternaam = 'Laarakkers'");
      echo "Het emailadres van Bibiche Laarakkers is $email.";

    $productInfo = $database->selectSingleRow("SELECT gewicht, prijs, calorieen FROM product WHERE naam = 'Sausage Muffin with Egg Whites'");
      echo "<h2> Sausage Muffin with Egg Whites </h2>";
      echo "<p>Gewicht: " . $productInfo['gewicht'] . "<br>";
      echo "Prijs: " . $productInfo['prijs'] . "<br>";
      echo "Aantal Calorieën: " . $productInfo['calorieen'] . "</p>";

      $producten = $database->selectRows("SELECT naam, prijs FROM product");
          foreach($producten as $product) {
            echo "<p class='pruducten'> Product:" . $product['naam'] . "<br>";
          echo "Prijs:" . $product['prijs'] . "</p>";

          }
?>

P粉596191963
P粉596191963

全部回复(1)
P粉726234648

如果您尝试在 php 代码中打印链接,您可以尝试这样的操作并看看它是否有效吗?

我使用 echo 的原因是它会打印出样式表的代码。如果我将代码直接放入 php 中间而不对其进行回显或将其包装在 '' 中,它将无法正确显示或打印。

';

    $email = $database->selectValue("SELECT emailadres FROM klant WHERE naam = 'Bibiche' AND achternaam = 'Laarakkers'");
      echo "Het emailadres van Bibiche Laarakkers is $email.";

    $productInfo = $database->selectSingleRow("SELECT gewicht, prijs, calorieen FROM product WHERE naam = 'Sausage Muffin with Egg Whites'");
      echo "

Sausage Muffin with Egg Whites

"; echo "

Gewicht: " . $productInfo['gewicht'] . "
"; echo "Prijs: " . $productInfo['prijs'] . "
"; echo "Aantal Calorieën: " . $productInfo['calorieen'] . "

"; $producten = $database->selectRows("SELECT naam, prijs FROM product"); foreach($producten as $product) { echo "

Product:" . $product['naam'] . "
"; echo "Prijs:" . $product['prijs'] . "

"; } ?>

如果这不起作用,因为 css 链接最好在文档的 部分中使用,您可以通过回显代码将代码直接打印到其中,以便它正确地将其打印到页面上。像这样:


    .pruducten {
        font-size:1rem;
    }
    ';
    $email = $database->selectValue("SELECT emailadres FROM klant WHERE naam = 'Bibiche' AND achternaam = 'Laarakkers'");
      echo "Het emailadres van Bibiche Laarakkers is $email.";

    $productInfo = $database->selectSingleRow("SELECT gewicht, prijs, calorieen FROM product WHERE naam = 'Sausage Muffin with Egg Whites'");
      echo "

Sausage Muffin with Egg Whites

"; echo "

Gewicht: " . $productInfo['gewicht'] . "
"; echo "Prijs: " . $productInfo['prijs'] . "
"; echo "Aantal Calorieën: " . $productInfo['calorieen'] . "

"; $producten = $database->selectRows("SELECT naam, prijs FROM product"); foreach($producten as $product) { echo "

Product:" . $product['naam'] . "
"; echo "Prijs:" . $product['prijs'] . "

"; } ?>

如果您绝对必须用 php 代码打印页面的每个方面,以上就是我的方法。

还有其他方法可以通过直接在 php 文件中使用 html 来实现此目的,例如确保它具有 部分等。但我想沿着您所走的道路努力,以更好地帮助您解决问题。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!