So ändern Sie das Erscheinungsbild von Absätzen in PHP-Dateien
P粉596191963
P粉596191963 2024-01-29 15:04:44
0
1
481

Ich habe versucht, die Datei als HTML-Datei zu erstellen oder einfach das <link rel="stylesheet" type="text/css" href="mystyle.css"> direkt einzufügen, aber es funktioniert nicht. Ich möchte die Schriftgröße des Absatzes „Produkte“ ändern können. Das ist mein bisheriger Code (über den letzten Teil())

<?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

Antworte allen(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 来实现此目的,例如确保它具有 部分等。但我想沿着您所走的道路努力,以更好地帮助您解决问题。

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage