Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <%@page import="java.sql.*"%>
- <html>
- <title>Unharmed Gaming</title>
- <link href="styles.css" type="text/css" rel="stylesheet"></link>
- <link rel="stylesheet"
- href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
- <link rel="stylesheet" href="nivo-slider3.2/nivo-slider/nivo-slider.css"
- type="text/css" />
- <script
- src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"
- type="text/javascript"></script>
- <script src="nivo-slider3.2/nivo-slider/jquery.nivo.slider.pack.js"
- type="text/javascript"></script>
- <link rel="stylesheet"
- href="nivo-slider3.2/nivo-slider/themes/default/default.css"
- type="text/css" />
- <link rel="shortcut icon" href="images/favicon-16x16.png">
- <link href="https://fonts.googleapis.com/css?family=Slabo+27px"
- rel="stylesheet">
- <link href="https://fonts.googleapis.com/css?family=Merriweather"
- rel="stylesheet">
- <%
- String gamename = request.getParameter("gamename");
- // Declaration of Variables
- int gameid = 0;
- String game_title = "";
- String company = "";
- String price = "";
- String release_date = "";
- String description = "";
- String image_loc = "";
- String preowned = "";
- int[] genreid = new int[15];
- String genrename = "";
- String commentor = "";
- int rating = 0;
- String displaycomments = "";
- String date_of_comments = "";
- try {
- // Step1: Load JDBC Driver
- Class.forName("com.mysql.jdbc.Driver");
- // Step 2: Define Connection URL
- String connURL = "jdbc:mysql://localhost/assignment?user=root&password=password&serverTimezone=UTC";
- // Step 3: Establish connection to URL
- Connection conn = DriverManager.getConnection(connURL);
- //Step 4: Create Statement object
- PreparedStatement pstmt = conn.prepareStatement("SELECT * from games where game_title=?");
- pstmt.setString(1, gamename);
- ResultSet rs = pstmt.executeQuery();
- // Loops through the selected game_title to obtain the attributes for the selected game_title
- while (rs.next()) {
- gameid = rs.getInt("gameid");
- game_title = rs.getString("game_title");
- company = rs.getString("company");
- price = rs.getString("price");
- release_date = rs.getString("release_date");
- description = rs.getString("description");
- image_loc = rs.getString("image_location");
- preowned = rs.getString("preowned");
- out.print("<h6>" + game_title + "</h6><br/>");
- out.print("<article class='whitecolour'> Genre(s): </article> ");
- PreparedStatement pstmt2 = conn.prepareStatement(
- "SELECT * from genre,game_genre where genre.genreid=game_genre.genreid and game_genre.gameid=?");
- pstmt2.setInt(1, gameid);
- ResultSet rs2 = pstmt2.executeQuery();
- // Loops through the selected table to display the genres of the game
- while (rs2.next()) {
- genrename = rs2.getString("genrename");
- out.print("<article class='whitecolour'>" + genrename + "</article> ");
- }
- // Displaying the selected game attributes
- out.print("<br/>");
- out.print("<article>");
- out.print("<figure>");
- out.print("<img src=\"images/" + image_loc
- + "\" class=\"imageforallgames\" width=\"530\" height=\"200\" alt=\"games picture\" onerror=\"this.src='images/unharmed.png'\">");
- out.print("</figure>");
- out.print("Company: " + company + "<br/>");
- out.print("Price: $" + price + "<br/>");
- out.print("Release Date: " + release_date + "<br/>");
- out.print("Description: " + description + "<br/>");
- out.print("Preowned: " + preowned + "<br/><br/>");
- out.print("</article>");
- }
- %>
- <table>
- <!-- Form for Inserting Comments for Selected Game -->
- <form action="insertcomments.jsp">
- <tr>
- <td>Name:</td>
- <td><input type="text" name="name" placeholder="Enter Your Name"></td>
- <br />
- <td><input type="hidden" name="gamename" value="<%=game_title%>"></td>
- <br />
- </tr>
- <tr>
- <td>Rating:</td>
- <td><select name="rating">
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- </select></td>
- <br />
- </tr>
- <tr>
- <td>Comments:</td>
- <br />
- <td><textarea name="comments" rows="5" cols="30"
- placeholder="Insert Your Comments Here" required></textarea></td>
- <br />
- </tr>
- <tr>
- <td><input type="submit" name="submit" value="Submit"></td>
- </tr>
- </form>
- </table>
- <%
- PreparedStatement pstmt3 = conn.prepareStatement("SELECT * from comment where gameid=?");
- pstmt3.setInt(1, gameid);
- ResultSet rs3 = pstmt3.executeQuery();
- // Loops through comment table for matching gameid
- while (rs3.next()) {
- commentor = rs3.getString("name");
- rating = rs3.getInt("rating");
- displaycomments = rs3.getString("comments");
- date_of_comments = rs3.getString("dateofcomment");
- // Displaying of comments of selected game
- out.print("<article>");
- out.print("<div class='firstcomment'>");
- out.print(commentor + "<br/><br/>");
- out.print(date_of_comments + "<br/>");
- out.print(rating + " star<br/><br/>");
- out.print(displaycomments + "<br/><br/>");
- out.print("</div>");
- out.print("</article>");
- }
- out.print("<p class='center'>");
- out.print("<a href='index.jsp' class='button3'>Back to home </a>");
- out.print("</p>");
- conn.close();
- } catch (Exception e) {
- out.println("Error :" + e);
- }
- //out.print(gamename);
- %>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement