Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/jquery.uniform.js" type="text/javascript" charset="utf-8"></script>
- <script type="text/javascript" charset="utf-8">
- $(function(){
- $("input, textarea, select, button").uniform();
- });
- </script>
- <link rel="stylesheet" href="css/uniform.default.css" type="text/css" media="screen">
- </head>
- <body>
- <?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');
- $gamesTag = $scores -> getElementsByTagName('Games') ->item(0);
- //Loop through each found game
- foreach ($games as $game) {
- $child = $game->getElementsByTagName("Date")->item(0);
- $oldHeader = $game->getElementsByTagName("Header")->item(0);
- $oldRow = $game->getElementsByTagName("Row")->item(0);
- $oldDate = $game->getElementsByTagName("Date")->item(0);
- $oldTime = $game->getElementsByTagName("Time")->item(0);
- $oldHomeTeam = $game->getElementsByTagName("HomeTeam")->item(0);
- $oldScore = $game->getElementsByTagName("Score")->item(0);
- $oldAwayTeam = $game->getElementsByTagName("AwayTeam")->item(0);
- $oldOther = $game->getElementsByTagName("Other")->item(0);
- $oldInfoID = $game->getElementsByTagName("InfoID")->item(0);
- $oldInfoData = $game->getElementsByTagName("InfoData")->item(0);
- $time = $child->nodeValue;
- if($time==$_GET['e']){ //The date is the date asked for.
- if(isset($_GET['delete'])){ //Delete
- $gamesTag->removeChild($game);
- }
- else{ //Update
- $h = $scores -> createElement("Header"); //Create a empty <Header> tag
- $h -> appendChild($scores ->createCDATASection ($_GET['header'])); //Add a CDATA element to it
- $game -> replaceChild($h,$oldHeader); //Then append it to the game tag
- $game -> replaceChild($scores -> createElement("Row", $_GET['row']),$oldRow);
- $game -> replaceChild($scores -> createElement("Date", $_GET['date']),$oldDate);
- $game -> replaceChild($scores -> createElement("Time", $_GET['time']),$oldTime);
- $game -> replaceChild($scores -> createElement("HomeTeam", $_GET['hometeam']),$oldHomeTeam);
- $game -> replaceChild($scores -> createElement("Score", $_GET['score']),$oldScore);
- $game -> replaceChild($scores -> createElement("AwayTeam", $_GET['awayteam']),$oldAwayTeam);
- $game -> replaceChild($scores -> createElement("Other", $_GET['other']),$oldOther);
- $game -> replaceChild($scores -> createElement("InfoID", $_GET['infoid']),$oldInfoID);
- $game -> replaceChild($scores -> createElement("InfoData", $_GET['infodata']),$oldInfoData);
- }
- }
- }
- //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.
- $date = $game->getElementsByTagName("Date")->item(0)->nodeValue;
- $header = $game->getElementsByTagName("Header")->item(0)->nodeValue;
- $row = $game->getElementsByTagName("Row")->item(0)->nodeValue;
- $date = $game->getElementsByTagName("Date")->item(0)->nodeValue;
- $time = $game->getElementsByTagName("Time")->item(0)->nodeValue;
- $hometeam = $game->getElementsByTagName("HomeTeam")->item(0)->nodeValue;
- $score = $game->getElementsByTagName("Score")->item(0)->nodeValue;
- $awayteam = $game->getElementsByTagName("AwayTeam")->item(0)->nodeValue;
- $other = $game->getElementsByTagName("Other")->item(0)->nodeValue;
- $infoid = $game->getElementsByTagName("InfoID")->item(0)->nodeValue;
- $infodata = $game->getElementsByTagName("InfoData")->item(0)->nodeValue;
- echo "
- <form method='get' action=''>
- <input type='hidden' name ='e' value='$date'>
- <table id='table2'><tr><td>Header:</td><td>Row: </td><td>Date: </td><td>Time: </td><td>HomeTeam: </td><td>Score: </td><td>AwayTeam: </td><td>Other: </td><td>InfoID: </td><td>InfoData: </td><td>Delete: </td></tr>
- <tr><td><textarea name='header'>$header</textarea></td>
- <td><input type='text' size='1' value='$row' name='row'></td>
- <td><input type='text' size='14' value='$date' name='date'></td>
- <td><input type='text' size='10' value='$time' name='time'></td>
- <td><input type='text' size='8' value='$hometeam' name='hometeam'></td>
- <td><input type='text' size='1' value='$score' name='score'></td>
- <td><input type='text' size='8' value='$awayteam' name='awayteam'></td>
- <td><input type='text' size='2' value='$other' name='other'></td>
- <td><input type='text' size='2' value='$infoid' name='infoid'></td>
- <td><textarea name='infodata' cols='60' rows='3'>$infodata</textarea></td>
- <td><input type='checkbox' name='delete'></td>
- <td><input type='submit' value='edit'></td><tr></table>
- </form>
- <hr width='1280px' style='margin-left:-5px;'>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement