Guest User

Untitled

a guest
Apr 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. <?php
  2. $db = mysql_connect('localhost','root','') or die ("Not Connected");
  3. mysql_select_db('moviesite', $db) or die (mysql_error($db));
  4. if ((isset($_GET['action'])) && ($_GET['action']=='edit'))
  5. {//retrieve the record's information
  6. $query = 'SELECT
  7. movie_name, movie_type, movie_year, movie_leadactor, movie_director
  8. FROM
  9. movie
  10. WHERE
  11. movie_id = ' . $_GET['id'];
  12. $result = mysql_query($query, $db) or die (mysql_error($db));
  13. extract(mysql_fetch_assoc($result));
  14. } else {
  15. //set value to blank
  16. $movie_name='';
  17. $movie_type= 0;
  18. $movie_year=date('Y');
  19. $movie_leadactor = 0;
  20. $movie_director =0;
  21. }
  22. ?>
  23. <html>
  24. <head>
  25. <title><?php echo ucfirst((isset($_GET['action'])) && ($_GET['action']=='edit')) ; ?>Movie</title>
  26. </head>
  27. <body>
  28. <form action="commit.php?action=<?php echo ucfirst ((isset($_GET['action'])) && ($_GET['action']=='edit')) ; ?>&type=movie" method="post">
  29. <table>
  30. <tr>
  31. <td>Movie Name</td>
  32. <td><input type="text" name="movie_name"
  33. value="<?php echo $movie_name; ?>" /></td>
  34. </tr><tr>
  35. <td>Movie Type</td>
  36. <td><select name="movie_type">
  37. <?php
  38. //select the movie type information
  39. $query = 'SELECT
  40. movietype_id, movietype_label
  41. FROM
  42. movietype
  43. ORDER BY
  44. movietype_label';
  45. $result = mysql_query($query,$db) or die (mysql_error($db));
  46.  
  47. //populate the select options with the results
  48. while ($row = mysql_fetch_assoc($result))
  49. {
  50. foreach($row as $value)
  51. {
  52. if ($row['movietype_id'] == $movie_type)
  53. {
  54. echo '<option value="' . $row['movietype_id'] . '" selected="selected">';
  55. }
  56. else
  57. {
  58. echo '<option value="' . $row['movietype_id'] . '">';
  59. }
  60. echo $row['movietype_label'] . '</option>';
  61. }
  62. }
  63. ?>
  64. </select></td>
  65. </tr><tr>
  66. <td>Movie Year</td>
  67. <td><select name="movie_year">
  68. <?php
  69. //populate the select options with years
  70. for ($yr = date("Y"); $yr>= 1970; $yr--)
  71. {
  72. if ($yr ==$movie_year)
  73. {
  74. echo '<option value="' . $yr . '" selected="selected">' . $yr . '</option>';
  75. }
  76. else
  77. {
  78. echo '<option value="' . $yr . '">' . $yr . '</option>';
  79. }
  80. }
  81. ?>
  82. </select></td>
  83. </tr><tr>
  84. <td>Lead Actor></td>
  85. <td><select name="movie_leadactor">
  86. <?php
  87. //select actor records
  88. $query = 'SELECT
  89. people_id, people_fullname
  90. FROM
  91. people
  92. WHERE
  93. people_isactor = 1
  94. ORDER BY
  95. people_fullname';
  96. $result = mysql_query($query, $db) or die (mysql_error($db));
  97. //populate the select options with the results
  98. while ($row = mysql_fetch_assoc($result))
  99. {
  100. foreach($row as $value)
  101. {
  102. if($row['people_id'] == $movie_leadactor)
  103. {
  104. echo '<option value="' . $row['people_id'] . '"selected="selected">';
  105. }
  106. else
  107. {
  108. echo '<option value="' . $row['people_id'] . '">';
  109. }
  110. echo $row['people_fullname'] . '</option>';
  111. }
  112. }
  113. ?>
  114. </select></td>
  115. </tr><tr>
  116. <td>Director</td>
  117. <td><select name="movie_director">
  118. <?php
  119. //select director records
  120. $query = 'SELECT
  121. people_id, people_fullname
  122. FROM
  123. people
  124. WHERE
  125. people_isdirector = 1
  126. ORDER BY
  127. people_fullname';
  128. $result = mysql_query($query, $db) or die (mysql_error($db));
  129. //populate the select options with results
  130. while ($row = mysql_fetch_assoc($result))
  131. {
  132. foreach ($row as $value)
  133. {
  134. if ($row['people_id'] ==$movie_director)
  135. {
  136. echo '<option value="' . $row['people_id'] . '"selected="selected">';
  137. }
  138. else
  139. {
  140. echo '<option value="' . $row['people_id'] . '">';
  141. }
  142. echo $row['people_fullname'] . '</option>';
  143. }
  144. }
  145. ?>
  146. </select></td>
  147. </tr><tr>
  148. <td colspan="2" style="text-align:center;">
  149. <?php
  150. if ((isset($_GET['action'])) && ($_GET['action']=='edit'))
  151. {
  152. echo '<input type="hidden" value"' . $_GET['id'] . '" name="movie_id"/>';
  153. }
  154. ?>
  155. <input type="submit" name="submit" value="<?php echo ucfirst((isset($_GET['action'])) && ($_GET['action']=='edit')) ;?>" />
  156. </td>
  157. </tr>
  158. </table>
  159. </form>
  160. </body>
  161. </html>
Add Comment
Please, Sign In to add comment