次のphpスクリプトを修正して削除ボタンを含める簡単な方法はありますか?現在、ループ内の各アイテムには変更を送信するボタンがあります。要素とその子を単純に削除するボタンを追加したいと思います。
私は PHP が初めてなので、XML と組み合わせて使用する方法を理解しようとしています。どんな助けも大歓迎です。
ここにphpがあります
<?php
if(isset($_GET['e'])){ //If a date is submitted, edit it
//var_dump($_GET);die;
    //Load the scores XML file
    $scores = new DOMDocument();
    $scores -> load('content.xml');
    //Get the <Games> tag
    $games = $scores -> getElementsByTagName('brand');
    //Loop through each found game
    foreach ($games as $game) {
        $child = $game->getElementsByTagName("id")->item(0);
        $oldTitle = $game->getElementsByTagName("title")->item(0);
        $oldScore = $game->getElementsByTagName("schedule_date")->item(0);
        $oldRow = $game->getElementsByTagName("image")->item(0);
        $id = $child->nodeValue;
        if($id==$_GET['e']){ //The date is the date asked for.
            $game -> replaceChild($scores -> createElement("title", $_GET['title']),$oldTitle);
            $game -> replaceChild($scores -> createElement("schedule_date", $_GET['schedule_date']),$oldScore);
            $game -> replaceChild($scores -> createElement("image", $_GET['image']),$oldRow);
        }
    }
    //Save again
    $scores -> save('content.xml');
}
?>
<hr>
<?php
//Load the scores XML file
$scores = new DOMDocument();
$scores -> load('content.xml');
//Get the <Games> tag
$games = $scores -> getElementsByTagName('brand');
//Loop through each game
foreach ($games as $game) {
    //Print each with an edit link.
    $id = $game->getElementsByTagName("id")->item(0)->nodeValue;
    $title = $game->getElementsByTagName("title")->item(0)->nodeValue;
    $score = $game->getElementsByTagName("schedule_date")->item(0)->nodeValue;
    $row = $game->getElementsByTagName("image")->item(0)->nodeValue;
    echo '<h3>'.$id . '</h3>
    <form method="get" action="">
        <input type="hidden" name="e" value="'.$id.'">
        Title: <input type="text" value="'.$title.'" name="title"><br>
        Score: <input type="text" value="'.$score.'" name="schedule_date"><br>
        Row: <input type="text" value="'.$row.'" name="image"><br>
        <input type="submit" value="edit">
    </form>
    <hr>';
}
?>
ここにxmlの例があります
<brand>
<title></title>
<schedule_date></schedule_date>
<image></image>
</brand>