Advertisement
Guest User

Untitled

a guest
May 21st, 2012
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.34 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
  7. <script src="js/jquery.uniform.js" type="text/javascript" charset="utf-8"></script>
  8. <script type="text/javascript" charset="utf-8">
  9. $(function(){
  10. $("input, textarea, select, button").uniform();
  11. });
  12. </script>
  13. <link rel="stylesheet" href="css/uniform.default.css" type="text/css" media="screen">
  14. </head>
  15.  
  16. <body>
  17.  
  18. <?php
  19. if(isset($_GET['e'])){ //If a date is submitted, edit it
  20. //Load the scores XML file
  21. $scores = new DOMDocument();
  22. $scores -> load('scores.xml');
  23.  
  24. //Get the <Games> tag
  25. $games = $scores -> getElementsByTagName('Game');
  26. $gamesTag = $scores -> getElementsByTagName('Games') ->item(0);
  27.  
  28. //Loop through each found game
  29. foreach ($games as $game) {
  30. $child = $game->getElementsByTagName("Date")->item(0);
  31. $oldHeader = $game->getElementsByTagName("Header")->item(0);
  32. $oldRow = $game->getElementsByTagName("Row")->item(0);
  33. $oldDate = $game->getElementsByTagName("Date")->item(0);
  34. $oldTime = $game->getElementsByTagName("Time")->item(0);
  35. $oldHomeTeam = $game->getElementsByTagName("HomeTeam")->item(0);
  36. $oldScore = $game->getElementsByTagName("Score")->item(0);
  37. $oldAwayTeam = $game->getElementsByTagName("AwayTeam")->item(0);
  38. $oldOther = $game->getElementsByTagName("Other")->item(0);
  39. $oldInfoID = $game->getElementsByTagName("InfoID")->item(0);
  40. $oldInfoData = $game->getElementsByTagName("InfoData")->item(0);
  41. $time = $child->nodeValue;
  42. if($time==$_GET['e']){ //The date is the date asked for.
  43. if(isset($_GET['delete'])){ //Delete
  44. $gamesTag->removeChild($game);
  45. }
  46. else{ //Update
  47.  
  48. $h = $scores -> createElement("Header"); //Create a empty <Header> tag
  49. $h -> appendChild($scores ->createCDATASection ($_GET['header'])); //Add a CDATA element to it
  50. $game -> replaceChild($h,$oldHeader); //Then append it to the game tag
  51. $game -> replaceChild($scores -> createElement("Row", $_GET['row']),$oldRow);
  52. $game -> replaceChild($scores -> createElement("Date", $_GET['date']),$oldDate);
  53. $game -> replaceChild($scores -> createElement("Time", $_GET['time']),$oldTime);
  54. $game -> replaceChild($scores -> createElement("HomeTeam", $_GET['hometeam']),$oldHomeTeam);
  55. $game -> replaceChild($scores -> createElement("Score", $_GET['score']),$oldScore);
  56. $game -> replaceChild($scores -> createElement("AwayTeam", $_GET['awayteam']),$oldAwayTeam);
  57. $game -> replaceChild($scores -> createElement("Other", $_GET['other']),$oldOther);
  58. $game -> replaceChild($scores -> createElement("InfoID", $_GET['infoid']),$oldInfoID);
  59. $game -> replaceChild($scores -> createElement("InfoData", $_GET['infodata']),$oldInfoData);
  60. }
  61. }
  62. }
  63.  
  64. //Save again
  65. $scores -> save('scores.xml');
  66. }
  67. ?>
  68. <hr>
  69. <?php
  70. //Load the scores XML file
  71. $scores = new DOMDocument();
  72. $scores -> load('scores.xml');
  73.  
  74. //Get the <Games> tag
  75. $games = $scores -> getElementsByTagName('Game');
  76.  
  77. //Loop through each game
  78. foreach ($games as $game) {
  79. //Print each with an edit link.
  80. $date = $game->getElementsByTagName("Date")->item(0)->nodeValue;
  81. $header = $game->getElementsByTagName("Header")->item(0)->nodeValue;
  82. $row = $game->getElementsByTagName("Row")->item(0)->nodeValue;
  83. $date = $game->getElementsByTagName("Date")->item(0)->nodeValue;
  84. $time = $game->getElementsByTagName("Time")->item(0)->nodeValue;
  85. $hometeam = $game->getElementsByTagName("HomeTeam")->item(0)->nodeValue;
  86. $score = $game->getElementsByTagName("Score")->item(0)->nodeValue;
  87. $awayteam = $game->getElementsByTagName("AwayTeam")->item(0)->nodeValue;
  88. $other = $game->getElementsByTagName("Other")->item(0)->nodeValue;
  89. $infoid = $game->getElementsByTagName("InfoID")->item(0)->nodeValue;
  90. $infodata = $game->getElementsByTagName("InfoData")->item(0)->nodeValue;
  91. echo "
  92. <form method='get' action=''>
  93. <input type='hidden' name ='e' value='$date'>
  94. <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>
  95. <tr><td><textarea name='header'>$header</textarea></td>
  96. <td><input type='text' size='1' value='$row' name='row'></td>
  97. <td><input type='text' size='14' value='$date' name='date'></td>
  98. <td><input type='text' size='10' value='$time' name='time'></td>
  99. <td><input type='text' size='8' value='$hometeam' name='hometeam'></td>
  100. <td><input type='text' size='1' value='$score' name='score'></td>
  101. <td><input type='text' size='8' value='$awayteam' name='awayteam'></td>
  102. <td><input type='text' size='2' value='$other' name='other'></td>
  103. <td><input type='text' size='2' value='$infoid' name='infoid'></td>
  104. <td><textarea name='infodata' cols='60' rows='3'>$infodata</textarea></td>
  105. <td><input type='checkbox' name='delete'></td>
  106. <td><input type='submit' value='edit'></td><tr></table>
  107. </form>
  108. <hr width='1280px' style='margin-left:-5px;'>";
  109. }
  110. ?>
  111.  
  112. </body>
  113. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement