Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['e'])){ //If a date is submitted, edit it
- //Load the scores XML file
- $scores = new DOMDocument();
- $scores -> load('scores.xml');
- //Get the <Games> tag
- $games = $scores -> getElementsByTagName('Game');
- //Loop through each found game
- foreach ($games as $game) {
- $child = $game->getElementsByTagName("Date")->item(0);
- $oldScore = $game->getElementsByTagName("Score")->item(0);
- $oldRow = $game->getElementsByTagName("Row")->item(0);
- $time = $child->nodeValue;
- if($time==$_GET['e']){ //The date is the date asked for.
- $game -> replaceChild($scores -> createElement("Score", $_GET['score']),$oldScore);
- $game -> replaceChild($scores -> createElement("Row", $_GET['row']),$oldRow);
- }
- }
- //Save again
- $scores -> save('scores.xml');
- }
- ?>
- <hr>
- <?php
- //Load the scores XML file
- $scores = new DOMDocument();
- $scores -> load('scores.xml');
- //Get the <Games> tag
- $games = $scores -> getElementsByTagName('Game');
- //Loop through each game
- foreach ($games as $game) {
- //Print each with an edit link.
- $time = $game->getElementsByTagName("Date")->item(0)->nodeValue;
- $score = $game->getElementsByTagName("Score")->item(0)->nodeValue;
- $row = $game->getElementsByTagName("Row")->item(0)->nodeValue;
- echo "<h3>".$time . "</h3>
- <form method='get' action=''>
- <input type='hidden' name ='e' value='$time'>
- Score: <input type='text' value='$score' name='score'><br>
- Row: <input type='text' value='$row' name='row'><br>
- <input type='submit' value='edit'>
- </form>
- <hr>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement