我收到以下错误:
注意:未定义的变量:第29行的C:\ xampp \ htdocs \ Projekt \ Controller \ controller.php中的WohFK
当我试图将我的变量移交给控制器时
Select.php:
<html>
<head>
<script
src="https://code.jquery.com/jquery-1.11.1.min.js"></script> // JQuery Reference
<script
src="https://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<script
src="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/jqueryui/dataTables.jqueryui.js">
</script>
<link rel="stylesheet"
href="https://code.jquery.com/ui/1.10.3/themes/sunny/jquery-ui.css">
<link rel="stylesheet"
href="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/jqueryui/dataTables.jqueryui.css">
</head>
<body>
<table id="example">
<thead>
<th>Geschlecht</th><th>Vorname</th><th>Nachname</th><th>Alter</th><th>Strasse</th><th>Hausnummer</th><th>Postleitzahl</th><th>Wohnort</th><th>Telefonnummer</th><th>Email</th><th>Webseite</th><th>Wohn</th><th>KontaktFK</th><th>Anpassungen</th>
</thead>
<tbody>
<?php
$controller = new Controller();
foreach($entries as $entry){
echo '<tr><td>'.$entry['Geschlecht'].'</td><td>'.$entry['Vorname'].'</td><td>'.$entry['Nachname'].'</td><td>'.$entry['Alter'].'</td><td>'.$entry['Strasse'].'</td><td>'.$entry['Hausnummer'].'</td>
<td>'.$entry['PLZ'].'</td><td>'.$entry['Ortsname'].'</td><td>'.$entry['Telefonnummer'].'</td><td>'.$entry['Email'].'</td><td>'.$entry['Webseite'].'</td><td class = "hidden">'.$entry['WohnortFK'].'</td><td>'.$entry['KontaktFK'].'</td>
<td><a href="?c=Controller&a=Delete&WohFK='.$controller->Delete($entry['WohnortFK']).'">Delete</a></td>
</tr>';
}
?>
</tbody>
</table>
<script>
$(function(){
$("#example").dataTable();
})
</script>
</body>
</html>
Controller.php这样:
class Controller
{
public function __construct()
{
include_once 'Model/Db.php';
}
public function form()
{
include 'view/Erfassung.php';
}
public function Select()
{
$Select = new datenverarbeitung();
$entries = $Select->FetchData();
include 'view/Select.php';
}
public function Delete($WohFK)
{
echo $WohFK;
}
public function Datafetch()
{
$array = array();
$Datasend = new datenverarbeitung();
$array[0] = $_POST['Geschlecht'];
$array[1] = $_POST['Vorname'];
$array[2] = $_POST['Nachname'];
$array[3] = $_POST['Alter'];
$array[4] = $_POST['Telefonnummer'];
$array[5] = $_POST['Email'];
$array[6] = $_POST['Webseite'];
$array[7] = $_POST['Strasse'];
$array[8] = $_POST['Hausnummer'];
$array[9] = $_POST['Postleitzahl'];
$array[10] = $_POST['Wohnort'];
$Datasend->InsertDataWohnort($array);
}
public
function Test($WohFK)
{
echo $WohFK;
}
}
Navigation.php:
if(isset($_GET['c'])){
if(include 'controller/' . strtolower($_GET['c']) . '.php'){
$controller = new $_GET['c']();
if(isset($_GET['a']) &&
method_exists($controller, $_GET['a'])){
$controller->$_GET['a']();
}
}else{
echo 'Seite nicht gefunden';
}