0
私はMLBについての学校のウェブサイトをデータベースで作成しています。しかし今、私はデータベースの情報をドロップダウンリストのオプションとして欲しがっています。オプションはteamnamesだろうデータベース情報をドロップダウンリストオプションとして使用
<!DOCTYPE html>
<html>
<head>
<link rel="icon" type="image/png" href="./images/favicon-32x32.png"
sizes="32x32" />
<link rel="icon" type="image/png" href="./images/favicon-16x16.png"
sizes="16x16" />
<title>MLB: Major League Baseball</title>
<link href="css folder/MLBstylesheet.css" rel="stylesheet"
type="text/css"/>
</head>
<body>
<div id="container">
<div id="titel">
<img class="MLBTitel" src="./images/MLBtitel.jpg" alt="MLBTitel" >
<div id="titeltekst">
MAJOR LEAGUE BASEBALL
<br>
</div>
<nav>
<ul>
<li><a class= "menu" href="index.html">Home</a></li>
<li><a class= "menu" href="spelers.php">Spelers</a></li>
<li><a id = "active" class= "menu" href="teams.php">Teams</a></li>
<li><a class= "menu" href="wedstrijden.html">Wedstrijden</a></li>
<li><a class= "menu" href="contact.html">Contact</a></li>
</ul>
</nav>
<br><br>
</div>
<div id="teamtabel">
<?php
$servername = "localhost";
$username = "id1419279_root";
$password = "*******";
$dbname = "id1419279_mlb";
// Create connection
$conn = new mysqli($localhost, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM teams";
$result = $conn->query($sql);
echo "<select name='naamteam'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['teamnaam'] ."'>" . $row['teamnaam'] ."
</option>";
}
echo "</select>";
?>
</div>
</div>
</body>
</html>
が、私のドロップダウンリストが空のままであるように思える::これは私のHTMLコードですpicture of the dropdownlist on the website これは私のデータベースは次のようになります。 picture of my database
私は誰かがことを願っ私を助け、私は本当にそれを感謝します。
whileの外側で$ rows = mysql_fetch_array($ result)を移動してみてください。そしてwhile($ rows as $ row){}を使うか、https://stackoverflow.com/questions/2974011/while-row-mysql-fetch-arrayresult-how-many-loops-are-being-performedを読んでください。 –