Guest User

Untitled

a guest
Feb 19th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.31 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "dc-heroes";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9.  
  10. if(isset($_GET['heroId'])) {
  11. $heroId = $_GET['heroId'];
  12. }
  13.  
  14. // Check connection
  15. if ($conn->connect_error) {
  16. die("Connection failed: " . $conn->connect_error);
  17. }
  18.  
  19.  
  20. //Get all teams
  21. $sql2 = "SELECT * from team";
  22. $result2 = $conn->query($sql2);
  23.  
  24. //get specific hero from team
  25. if(isset($_GET['teamId']))
  26. {
  27. $sql = "SELECT * FROM hero WHERE teamId = " . $_GET['teamId'];
  28. }
  29. else {
  30. $sql = "SELECT * FROM hero";
  31. }
  32. $result = $conn->query($sql);
  33.  
  34.  
  35.  
  36. //Get hero details
  37. if (!isset($_GET['heroId'])) {
  38. $sql3 = "SELECT * from hero";
  39. }
  40. else {
  41. $sql3 = "SELECT * from hero WHERE heroId = " . $_GET['heroId'];
  42. }
  43. $result3 = $conn->query($sql3);
  44.  
  45. ?>
  46. <!DOCTYPE html>
  47. <html>
  48. <head>
  49. <meta charset="utf-8" />
  50. <meta name="description" content="Dc Univserse. - Biggest information site!">
  51. <link rel="stylesheet" type="text/css" href="css/style.css">
  52. <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet" type="text/css" />
  53. <link rel="icon" href="images/dc-logo.png" type="image/png">
  54. <title>Dc Universe</title>
  55. </head>
  56. <body>
  57. <header>
  58. <img src="images/dc-logo.png" width="100px" height="100px;" id="img-logo"><div class="logo"><a id="a_logo" href="index.php?teamId=1" style="text-decoration:none; font-family:verdana;">
  59. Heroes
  60. </a></div>
  61. </header>
  62. <div id="main-container">
  63. <div id="left-container">
  64. <nav>
  65. <h1>Teams</h1>
  66. <ul>
  67. <?php
  68. while($row2 = $result2->fetch_assoc()) {
  69. ?>
  70. <img height="80px" width="60px;" src="./<?php echo $row2["teamImage"]; ?>.jpg">
  71. <li><a href="index.php?teamId=<?php echo $row2['teamId'];?>" style="text-decoration:none;"><?php echo $row2["teamName"]; ?></a></li>
  72. <?php
  73. }
  74. ?>
  75. </ul>
  76. </nav>
  77. </div>
  78. <div id="center-container">
  79. <h1>Heroes</h1>
  80. <?php
  81. if ($result->num_rows > 0) {
  82. while($row3 = $result->fetch_assoc()) {
  83.  
  84. ?>
  85. <div class="hero-container">
  86. <div class="hero-image"><img height="200px" width="130px;" src="./<?php echo $row3["heroImage"]; ?>.jpg"></div>
  87. <div class="hero-description"><h3><?php echo $row3["heroName"]; ?></h3>
  88. <p><?php echo substr($row3["heroDescription"], 0, 80) . "..."; ?></p>
  89. <div class="button-hero1"><ul style="text-decoration:none;"><li style="text-decoration:none;"><a style="text-decoration:none;" href="index.php?teamId=<?php echo $row3['teamId']; ?>&heroId=<?php echo $row3['heroId']; ?>" style="font-size:15px">More info..</a></li></ul></div></div>
  90. </div>
  91. <?php
  92.  
  93. }
  94.  
  95. }
  96. else {
  97. echo "No results";
  98. }
  99.  
  100. ?>
  101. </div>
  102. <div id="right-container">
  103. <?php
  104. if(isset($heroId)) {
  105. ?>
  106.  
  107. <h1>Description</h1>
  108. <div class="right-box">
  109. <?php
  110. while($row3 = $result3->fetch_assoc()) {
  111. ?>
  112. <div class="top-part">
  113. <div id="h7"><h7><?php echo $row3['heroName']; ?></h7></div>
  114. <div class="mid-part-image">
  115. <img class="hero-image-round" height="200px" width="130px;" src="./<?php echo $row3["heroImage"]; ?>.jpg">
  116. </div>
  117. <div class="info-box">
  118. <h2>Info</h2>
  119. <p>
  120. <?php echo $row3['heroDescription']; ?>
  121. </p>
  122. <h2>Powers</h2>
  123. <ul>
  124. <li><?php echo $row3['heroPower']; ?></li>
  125. </ul>
  126. <?php
  127. }
  128. ?>
  129. </div>
  130. <h2>Rate your hero</h2>
  131. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" class="frmRate">
  132. <h4>Rating</h4>
  133. <div class="rate">
  134. <input type="radio" id="rating10" name="rating" value="10" />
  135. <label class="lblRating" for="rating10" title="5 stars"></label>
  136.  
  137.  
  138. <input type="radio" id="rating8" name="rating" value="8" />
  139. <label class="lblRating" for="rating8" title="4 stars"></label>
  140.  
  141.  
  142.  
  143. <input type="radio" id="rating6" name="rating" value="6" />
  144. <label class="lblRating" for="rating6" title="3 stars"></label>
  145.  
  146.  
  147. <input type="radio" id="rating4" name="rating" value="4" />
  148. <label class="lblRating" for="rating4" title="2 stars"></label>
  149.  
  150.  
  151. <input type="radio" id="rating2" name="rating" value="2" />
  152. <label class="lblRating" for="rating2" title="1 star"></label>
  153.  
  154.  
  155. <input type="radio" id="rating0" name="rating" value="0" />
  156. <label class="lblRating" for="rating0" title="No star"></label>
  157. </div>
  158.  
  159. <div class="review">
  160. <h4>Review</h4>
  161. <textarea class="text-area" rows="4" cols="50" name="comment" form="usrform">
  162. Enter text here...</textarea>
  163. </div>
  164. <div class="divSubmit">
  165. <input type="submit" name="submitRating" value="Rate Hero"/>
  166. <input type="hidden" name="heroId" value="<?php echo $heroId; ?>"/>
  167. </div>
  168. </form>
  169. </div>
  170.  
  171. </div>
  172. <?php
  173. } else {
  174. echo "please select an hero";
  175. }
  176. ?>
  177. </div>
  178.  
  179. </div>
  180. </div>
  181. </body>
  182. </html>
Add Comment
Please, Sign In to add comment