我有一个表单,其中包含从循环PHP数据生成的选项。我试图将选定的POST数据传递到同一页面进行处理。但是,出了点问题。我得到一个未定义的索引,print_r($ _ POST)显示一个空数组。有人可以帮忙吗?
<!DOCTYPE html>
<head>
<title>Inventory Tables</title>
</head>
<script src="../_js/jquery.min.js"></script>
<script src="../_js/jquery-ui.min.js"></script>
<body>
<?php //inventory mysql tables
ini_set('display_errors',1); error_reporting(E_ALL);
require_once 'inventoryconfig.php';
$connection = new mysqli($db_hostname, $db_username, $db_password, $db_database);
if ($connection->connect_error) die($connection->connect_error);
$result = $connection->query("SHOW TABLES");
$table = array();
while ($row = $result->fetch_row()){
$table[] = $row[0];
}
$count = count($table);
$all = "*";
?>
<?php if ($_SERVER['REQUEST_METHOD'] == 'GET') {?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="POST">
<select method="POST">
<option value=\"$all\">--Select--</option>\n";
<?php for ($pointer = 0 ; $pointer < $count ; ++$pointer) {
echo <<<_END
<pre>
<option name="$table[$pointer]" value="$table[$pointer]">$table[$pointer]</option>
</pre>
_END;
}
global $table;
global $pointer;
?>
</select>
<input type="submit" value="send">
</form>
<?php } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$thisTable = $_POST['$table[$pointer]'];
print_r($_POST);
echo $thisTable;
}
$connection->close();
?>
</body>
</html>