首頁  >  問答  >  主體

如何更改 php 檔案中段落的外觀

我嘗試將文件製作為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粉596191963P粉596191963238 天前398

全部回覆(1)我來回復

  • P粉726234648

    P粉7262346482024-01-30 09:38:37

    如果您嘗試在 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 連結最好在文件的 < head > 部分中使用,您可以透過回顯程式碼將程式碼直接列印到其中,以便它正確地將其列印到頁面上。像這樣:

    
        .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 來實現此目的,例如確保它具有 < head > 部分等。但我想沿著您所走的道路努力,以更好地幫助您解決問題。

    回覆
    0
  • 取消回覆