I want to fill some items from a database into a form as soon as somebody presses a button. Therefore I wrote some functions, which are saving the id
of the row in my database
(this id
is transmitted from the button) and then converting them into a fetch_object. This fetch_Object
then is supposed to get filled in the text-input fields of a form.
I am using XAMPP
.
function showEditForm($row) {
var_dump($row);
$name = $row->name;
$bewertung = $row->bewertung;
$bemerkung = $row->bemerkung;
echo <<<ENDE
<form action="main.php">
<form action="phpinfo.php" method="POST">
Name:<br>
<input type="text" name="name" value="$name"><br>
Bewertung (1-6):<br>
<input type="number" name="bewertung" min="1" max="6" value="$bewertung"><br>
Bemerkung:<br>
<input type="text" name="bemerkung" value="$bemerkung">
<input type="submit" value="senden">
</form>
ENDE;
}
if ($function == "edit") {
$id = $_GET['editEntry2'];
echo "id: $id <br>";
$row = $kneipen->selectOne($id);
print_r($row);
showEditForm($row);
showEditForm($id);
} else {
showList();
}
function nextRow(){
if (!$this->result) {
return false;
}
$row = $this->result->fetch_object();
return $row;
}
function selectOne($id){
$sql = "SELECT * FROM kneipen WHERE id = '$id'";
// echo "sql = $sql <br\>";
$this->result = $this->mysqli->query($sql);
if (!$this->result) {
echo("Errorcode: " . $this->mysqli->errno . " " . $this->mysqli->error);
}
return $this->nextRow();
}
Notice: Trying to get property 'name' of non-object in C:\Praktikanten\Elias\Programme\xampp-windows-x64-7.3.10-0-VC15\xampp\htdocs\Projekt KneipenDB\functionGUI.php on line 67
Notice: Trying to get property 'bewertung' of non-object in C:\Praktikanten\Elias\Programme\xampp-windows-x64-7.3.10-0-VC15\xampp\htdocs\Projekt KneipenDB\functionGUI.php on line 68
Notice: Trying to get property 'bemerkung' of non-object in C:\Praktikanten\Elias\Programme\xampp-windows-x64-7.3.10-0-VC15\xampp\htdocs\Projekt KneipenDB\functionGUI.php on line 69