Hello I am currently having an issue with my website, I have a basic list of Todo's that are accessed from phpMyAdmin database and I keep getting errors like this.. I cannot find a solution since I don't know what variable should be there
Notice: Undefined index: ID in C:\Users\User1\Downloads\COMP1006-W2017-MidTerm\COMP1006-W2017-MidTerm\index.php on line 59
Notice: Undefined index: todolistID in C:\Users\User1\Downloads\COMP1006-W2017-MidTerm\COMP1006-W2017-MidTerm\book_details.php on line 8
I have included a link to my github so you can see the files as they are. Any help is greatly appreciated (Don't worry about it being called Midterm, I simply am using a file I got working with another database and I am trying to replicated the results
https://github.com/AlexandreMelano/COMP1006-MidTerm-200249154
<?php
include_once('database.php'); // include the database connection file
/*//////////////////////*/
/* YOUR CODE GOES HERE */
/*/////////////////////*///
$todolistID = $_GET["todolistID"]; // assigns the gameID from the URL
echo $todolistID;
if($todolistID == 0) {
$todolist = null;
$isAddition = 1;
} else {
$isAddition = 0;
$query = "SELECT * FROM todolists WHERE Id = :todolist_id "; // SQL statement
$statement = $db->prepare($query); // encapsulate the sql statement
$statement->bindValue(':todolist_id', $todolistID);
$statement->execute(); // run on the db server
$book = $statement->fetch(); // returns only one record
$statement->closeCursor(); // close the connection
}
?>
next page
<?php
include_once('database.php');
$query = "SELECT * FROM todolists"; // SQL statement
$statement = $db->prepare($query); // encapsulate the sql statement
$statement->execute(); // run on the db server
$todolists = $statement->fetchAll(); // returns an array
$statement->closeCursor(); // close the connection
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Book List</title>
<!-- CSS Section -->
<link rel="stylesheet" href="./Scripts/lib/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="./Scripts/lib/bootstrap/dist/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="./Scripts/lib/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="./Content/app.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-offset-2 col-md-8">
<h1>Books List</h1>
<!-- /////////////////////////// -->
<!-- FIX THE ADD NEW BOOK BUTTON -->
<!-- /////////////////////////// -->
<a class="btn btn-primary" href="">
<a class="btn btn-primary" href="book_details.php?todolistID=0"><i class="fa fa-plus"></i> Add New Book</a>
<br>
<table class="table table-striped table-hover table-bordered">
<tr>
<th>ID</th>
<th>Todo</th>
<th>Notes</th>
<th></th>
<th></th>
</tr>
<?php foreach($todolists as $todolist) : ?>
<td><?php echo $todolist['Id'] ?></td>
<td><?php echo $todolist['TODO'] ?></td>
<td><?php echo $todolist['Notes'] ?></td>
<!-- //////////////////// -->
<!-- MODIFY SECTION BELOW -->
<!-- //////////////////// -->
<td><a class="btn btn-primary" href="book_details.php?todolistID=<?php echo $todolist['Id'] ?>"><i class="fa fa-pencil-square-o"></i> Edit</a></td>
<td><a class="btn btn-danger" href="book_delete.php?todolistID=<?php echo $todolist['Id'] ?>"><i class="fa fa-trash-o"></i> Delete</a></td>
</tr>
<?php endforeach; ?>