1
我是一名學生(很新的PHP)導入的HTML元素的背景顏色試圖動態地改變每個「魚」的背景顏色中數據庫,但在此之前,我需要嘗試靜態更改背景,但是,我甚至無法做到這一點。我試圖用引號,引號和轉義字符來引用無效。非更新內嵌CSS時,試圖改變從MySQL數據庫
PHP/HTML
<html>
<head>
<title>Dinosaurs</title>
</head>
<body>
</body>
<?php
include 'connection.php';
$query = "SELECT Name FROM `fish` WHERE FishTypeID = 4";
if (!$result = $mysqli->query($query)){
echo "Sorry, the website is experiencing problems.";
echo "Error: Your query failed to execute and here is why: \n";
echo "Errno: " . $mysqli->errno . "\n";
echo "Error: " . $mysqli->error . "\n";
exit;
}
while ($row = mysqli_fetch_row($result)) {
print("<div background-color = \"blue\">
<h4>");
foreach ($row as $key => $value) {
print($value . "
<svg height = 64 width = 80>
<polygon points='1 31, 6 42, 1 47,26 63,60 50,80 64, 72 39, 80 16,60 28,26 17' />
<circle cx='20' cy='32' r='5' stroke='white' stroke-width='3' fill='black' />
</svg>");
}
print("</h4></div>");
}
?>
<h1>dinosaurs</h1>
</html>
你是對的,當你說你首先需要做沒有數據庫,但是這個代碼與數據庫組件 – e4c5
@ e4c5我有一個String嘗試過,但沒有奏效。 –
是你爲什麼通過添加數據庫相關的東西使它更復雜? – e4c5