Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Achievement CMS</title>
  4. </head>
  5. <body>
  6. <h1>Delete Games</h1>
  7.  
  8. <?php include_once('connect.php');
  9.  
  10. if (isset($_POST['title'])):
  11.  
  12. $title = $_POST['title'];
  13. $id = $_POST['id'];
  14. $sql = "UPDATE games SET
  15. title='$title' WHERE id='$id'";
  16. if (mysql_query($sql))
  17.  
  18. {
  19.     echo 'Game updated successfully <br><br>';
  20. } else {
  21.     'There was a problem updsating the game'.
  22.     'Error: ' . mysql_error() . '';
  23. }
  24. ?>
  25. <br>
  26. <a href="games.php">Return to Games list</a>
  27.  
  28. <?php else:
  29. $typeid =$_GET['typeid'];
  30. $id = $_GET['id'];
  31. $title = mysql_query("SELECT title FROM games WHERE id='$id'");
  32. $type = mysql_query("SELECT type FROM type WHERE typeid='$typeid'");
  33. $drop_down = mysql_query("SELECT * FROM type ORDER BY '$typeid'");
  34. if(!$title)
  35. {
  36.     exit('Error fetching game details: ' . mysql_error() . '');
  37. }
  38. if(!$type)
  39. {
  40.     exit('Error fetching game details: ' . mysql_error() . '');
  41. }
  42. if(!$drop_down)
  43. {
  44.     exit('Error fetching game details: ' . mysql_error() . '');
  45. }
  46. $title = mysql_fetch_array($title);
  47. $type = mysql_fetch_array($type);
  48.  
  49.  
  50. $name = $title['title'];
  51. $category = $type['type'];
  52. $type = $drop_down['type'];
  53. ?>
  54. <form action="<?php echo$_SERVER['PHP_SELF'];?>" method="post">
  55. <p>Edit the details below:</p>
  56. <label>Game title: <input type="text" name="title"  value="<?php echo $name; ?>"/></label><br>
  57. Game Category:
  58.  <?php
  59.     echo "<select name=\"name\">";
  60.     if(mysql_num_rows($drop_down))
  61.     {
  62.     while($row = mysql_fetch_assoc($drop_down))
  63.     {
  64.     echo "<option>$row[type]</option>";
  65.     }
  66.  
  67.     }
  68.     else {
  69.     echo "<option>No Names Present</option>";  
  70.     }
  71.     ?>
  72. <input type="hidden" name="id" value="<?php echo $id;?>"/>
  73. <input type="submit" value="Submit" />
  74. </form>
  75. <?php endif; ?>
  76.  
  77.     </td>
  78.     </tr>    
  79. </body>
  80. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement