私が書いたコードは機能しますが、それでも取得し続けます:
注意: 未定義のインデックス: C:\xampp\htdocs\portfolio\periode4\graden\array.php の 35 行目の id。
通知を取り除くために私がしなければならないことを誰か知っていますか?
<?php
function connect()
{
// Make a MySQL Connection
$link = mysqli_connect("localhost", "root", "", "school") or die(mysqli_error());
return $link;
}
if($_GET) {
$id = $_GET["id"];
}
// select query
$query = "SELECT * FROM graden" ;
$result = mysqli_query(connect(),$query);
// tabel maken
$table = "<table border='1'>";
$table .= "<tr>
<th> ID </th>
<th>Graden Celcius</th>
<th>Aanduiding</th>
<th>Image</th>
</tr>";
// keeps getting the next row until there are no more to get
while($row = mysqli_fetch_assoc( $result )) {
$table .="<tr ".($_GET['id'] == $row['id']?" style='background-color:yellow'":"").">";
// Print out the contents of each row into a table
foreach ($row as $key => $value)
{
if ($key == "Image")
{
$table .="<td><img src='$value' /></td>";
}
elseif ($key == "id")
{
$table .="<td><a href='array.php?id=$value'>$value</a></td>";
}
else
{
$table .="<td>$value</td>";
}
}
$table .= "</tr>";
}
$table .="</table>";
echo $table;
// optie lijst
//maken select query
$query = "SELECT id, temp FROM graden ";
//uitvoeren select query
$result = mysqli_query(connect(), $query) ;
//tonen alle gegevens
$select = "
<form action=\"array.php\" method=\"get\">\n
<select name=\"id\">\n
<option value='id'>---all---</option>\n
";
while($row = mysqli_fetch_assoc( $result ))
{
$select .= "<option value='".$row['id']."'>".$row["temp"]."</option>\n";
}
$select .= "</select>\n";
$select .= "<input type=\"submit\">\n";
$select .= "</form>\n";
echo $select;