如何更改 php 檔案中段落的外觀
P粉596191963
P粉596191963 2024-01-29 15:04:44
0
1
476

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

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板