0
調用函數內的變量I根據輸入I輸入試圖在PHP
這裏想程序,顯示我的數據的基礎上的元件的功能是我的代碼,但我就行得到一個錯誤34
注意:未定義指數:表[1] [ 「des_dem」]在 C:\ XAMPP \ htdocs中\ GPC \ test.php的在線路34上
<?php
$element = $_GET["element"];
echo $element;
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "gpc";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// $sql = "SELECT * FROM bons WHERE des_dem='$element'" ;
$sql = "SELECT * FROM bons" ;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$table = $result->fetch_all(MYSQLI_ASSOC);
} else {
echo "0 results";
}/*
echo $table[1]["des_dem"];
echo "<br>";
echo $table[1]["des_dec"]; */
function afficher()
{
echo $GLOBALS['table[1]["des_dem"]'];
}
echo $table[4]["des_dec"];
echo "<br>";
afficher();
$conn->close(); ?>
<html>
<body>
<br>
<form action="test.php" method="get">
<tr>
<td>Name</td>
<td><input type="text" name="element"></td>
</tr>
<input type="submit" value="Submit">
</form>
</body>
</html>
非常感謝回答我尋求離子:)
這應該是:'回聲$ GLOBALS [ $表[1] [ 「des_dem」]];' – devpro