ユーザーがMYSQLデータベースに保存したアイテムを表示し、チェックボックスとともにエコーアウトするページがあります。ユーザーがこのチェックボックスをクリックして保存ボタンをクリックすると、レコードが削除されますが、タイトルにエラーが表示されます。
休日フォームを表示します。
<form action="deleteProcess.php">
<?php
foreach($db->query($sql) as $row)
{
echo "<p>" . $row['title'] . "<br \>" .
$row['description'] . "<br \>" .
$row['link'] . "<br \>" .
$row['pubDate'] .
"<input type='checkbox' name='del[]' value='$row/['title'/]'/>" .
"</p>";
}
?>
<input type="submit" name="delete" value="submit" />
</form>
process.phpを削除します
foreach($_POST['del'] as $check_value)
{
//takes session value and assigns it to a variable so that when a holiday is saved it can be distinguished by user
$user = $_SESSION['name'];
//assign the value of previous checkbox to $check
$check = $check_value;
//assign xpath query to variable $fav
$fav = "channel/item [title = \"$check\"]";
//loads instance of xml file as $holidayDoc
$holidayDoc = simplexml_load_file('holidays.xml');
//executes xpath search within holidays.xml and results stored in $favourites
$favourites = $holidayDoc->xpath($fav);
//for each element of the associative array $favourites, key will be referred to as $currentFav.
foreach($favourites as $currentFav)
{
echo "{$currentFav->link}". "<br \>";
echo "{$currentFav->title}". "<br \>";
echo "{$currentFav->description}". "<br \>";
echo "{$currentFav->pubDate} ". "<br \>";
//sql statement that states which values will be inserted into which column
$sql = "DELETE FROM `saved_holidays` (`subscriberID`, `link`, `pubDate`, `title`, `description`)
VALUES ('$user', '$currentFav->link', '$currentFav->pubDate', '$currentFav->title', '$currentFav->description')";
//connect to database then execute the sql statement.
$db->exec($sql);
//close connection to the database
$db = null;
エラーがforeach($_POST['del'] as $check_value)
行に表示されており、なぜそれが機能しないのか理解できません。助けていただければ幸いです。
注意:未定義のインデックス:14行目の/var/www/vhosts/numyspace.co.uk/web_users/home/~unn_w11026991/public_html/Ass/deleteProcess.phpのdel
警告:14行目の/var/www/vhosts/numyspace.co.uk/web_users/home/~unn_w11026991/public_html/Ass/deleteProcess.phpのforeach()に無効な引数が指定されています