SHARE
TWEET

Untitled

a guest May 21st, 2019 138 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2.     pageEncoding="ISO-8859-1"%>
  3. <%@page import="java.sql.*"%>
  4. <html>
  5. <title>Unharmed Gaming</title>
  6. <link href="styles.css" type="text/css" rel="stylesheet"></link>
  7.  
  8. <link rel="stylesheet"
  9.     href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  10.  
  11. <link rel="stylesheet" href="nivo-slider3.2/nivo-slider/nivo-slider.css"
  12.     type="text/css" />
  13. <script
  14.     src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"
  15.     type="text/javascript"></script>
  16. <script src="nivo-slider3.2/nivo-slider/jquery.nivo.slider.pack.js"
  17.     type="text/javascript"></script>
  18. <link rel="stylesheet"
  19.     href="nivo-slider3.2/nivo-slider/themes/default/default.css"
  20.     type="text/css" />
  21.  
  22. <link rel="shortcut icon" href="images/favicon-16x16.png">
  23. <link href="https://fonts.googleapis.com/css?family=Slabo+27px"
  24.     rel="stylesheet">
  25. <link href="https://fonts.googleapis.com/css?family=Merriweather"
  26.     rel="stylesheet">
  27. <%
  28.     String gamename = request.getParameter("gamename");
  29. // Declaration of Variables
  30.     int gameid = 0;
  31.     String game_title = "";
  32.     String company = "";
  33.     String price = "";
  34.     String release_date = "";
  35.     String description = "";
  36.     String image_loc = "";
  37.     String preowned = "";
  38.     int[] genreid = new int[15];
  39.     String genrename = "";
  40.  
  41.     String commentor = "";
  42.     int rating = 0;
  43.     String displaycomments = "";
  44.     String date_of_comments = "";
  45.     try {
  46.         // Step1: Load JDBC Driver
  47.         Class.forName("com.mysql.jdbc.Driver");
  48.  
  49.         // Step 2: Define Connection URL
  50.         String connURL = "jdbc:mysql://localhost/assignment?user=root&password=password&serverTimezone=UTC";
  51.  
  52.         // Step 3: Establish connection to URL
  53.         Connection conn = DriverManager.getConnection(connURL);
  54.         //Step 4: Create Statement object
  55.         PreparedStatement pstmt = conn.prepareStatement("SELECT * from games where game_title=?");
  56.         pstmt.setString(1, gamename);
  57.         ResultSet rs = pstmt.executeQuery();
  58.         // Loops through the selected game_title to obtain the attributes for the selected game_title
  59.         while (rs.next()) {
  60.             gameid = rs.getInt("gameid");
  61.             game_title = rs.getString("game_title");
  62.             company = rs.getString("company");
  63.             price = rs.getString("price");
  64.             release_date = rs.getString("release_date");
  65.             description = rs.getString("description");
  66.             image_loc = rs.getString("image_location");
  67.             preowned = rs.getString("preowned");
  68.             out.print("<h6>" + game_title + "</h6><br/>");
  69.             out.print("<article class='whitecolour'> Genre(s): </article> ");
  70.             PreparedStatement pstmt2 = conn.prepareStatement(
  71.                     "SELECT * from genre,game_genre where genre.genreid=game_genre.genreid and game_genre.gameid=?");
  72.             pstmt2.setInt(1, gameid);
  73.             ResultSet rs2 = pstmt2.executeQuery();
  74.             // Loops through the selected table to display the genres of the game
  75.             while (rs2.next()) {
  76.                 genrename = rs2.getString("genrename");
  77.                 out.print("<article class='whitecolour'>" + genrename + "</article> ");
  78.             }
  79.             // Displaying the selected game attributes
  80.             out.print("<br/>");
  81.             out.print("<article>");
  82.             out.print("<figure>");
  83.             out.print("<img src=\"images/" + image_loc
  84.                     + "\" class=\"imageforallgames\" width=\"530\" height=\"200\" alt=\"games picture\" onerror=\"this.src='images/unharmed.png'\">");
  85.             out.print("</figure>");
  86.             out.print("Company: " + company + "<br/>");
  87.             out.print("Price: $" + price + "<br/>");
  88.             out.print("Release Date: " + release_date + "<br/>");
  89.             out.print("Description: " + description + "<br/>");
  90.             out.print("Preowned: " + preowned + "<br/><br/>");
  91.             out.print("</article>");
  92.         }
  93. %>
  94. <table>
  95. <!-- Form for Inserting Comments for Selected Game -->
  96.     <form action="insertcomments.jsp">
  97.         <tr>
  98.             <td>Name:</td>
  99.             <td><input type="text" name="name" placeholder="Enter Your Name"></td>
  100.             <br />
  101.             <td><input type="hidden" name="gamename" value="<%=game_title%>"></td>
  102.             <br />
  103.         </tr>
  104.         <tr>
  105.             <td>Rating:</td>
  106.             <td><select name="rating">
  107.                     <option value="1">1</option>
  108.                     <option value="2">2</option>
  109.                     <option value="3">3</option>
  110.                     <option value="4">4</option>
  111.                     <option value="5">5</option>
  112.             </select></td>
  113.             <br />
  114.         </tr>
  115.         <tr>
  116.             <td>Comments:</td>
  117.             <br />
  118.             <td><textarea name="comments" rows="5" cols="30"
  119.                     placeholder="Insert Your Comments Here" required></textarea></td>
  120.             <br />
  121.         </tr>
  122.         <tr>
  123.             <td><input type="submit" name="submit" value="Submit"></td>
  124.         </tr>
  125.     </form>
  126. </table>
  127. <%
  128.     PreparedStatement pstmt3 = conn.prepareStatement("SELECT * from comment where gameid=?");
  129.         pstmt3.setInt(1, gameid);
  130.         ResultSet rs3 = pstmt3.executeQuery();
  131.         // Loops through comment table for matching gameid
  132.         while (rs3.next()) {
  133.             commentor = rs3.getString("name");
  134.             rating = rs3.getInt("rating");
  135.             displaycomments = rs3.getString("comments");
  136.             date_of_comments = rs3.getString("dateofcomment");
  137.             // Displaying of comments of selected game
  138.             out.print("<article>");
  139.             out.print("<div class='firstcomment'>");
  140.             out.print(commentor + "<br/><br/>");
  141.             out.print(date_of_comments + "<br/>");
  142.             out.print(rating + " star<br/><br/>");
  143.             out.print(displaycomments + "<br/><br/>");
  144.             out.print("</div>");
  145.             out.print("</article>");
  146.         }
  147.         out.print("<p class='center'>");
  148.         out.print("<a href='index.jsp' class='button3'>Back to home </a>");
  149.         out.print("</p>");
  150.         conn.close();
  151.     } catch (Exception e) {
  152.         out.println("Error :" + e);
  153.     }
  154.     //out.print(gamename);
  155. %>
  156.  
  157. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top