Jump to content

Revolutsio

Members
  • Posts

    85
  • Joined

  • Last visited

Everything posted by Revolutsio

  1. <?php include 'includes/config2.php'; //Check GET request id param if(isset($_GET['id'])){ $id = mysqli_real_escape_string($db, $_GET['id']); // make sql $sql = "SELECT * FROM games WHERE id= $id"; // get the query result $result = mysqli_query($db, $sql); // fetch result in array format $game = mysqli_fetch_assoc($result); mysqli_free_result($result); mysqli_close($db); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="/includes/home.css"> <Title>Game Library - Details</Title> </head> <body> <div class="wrapper"> <div class="span-col-4"><img src="images/logo2.png"></div> <div class="span-col-4"><?php include 'includes/navbar.php'; ?></div> <div class="span-col-4"> <div class="text-display text-shadow box-shadow"> <?php echo htmlspecialchars($game['game']); ?></div> </div> <div class="span-col-4"> <div class="picture_details"> <?php echo "<img class='img_details box-shadow' src='images/" . $game['image_name'] ."' >"?> </div> <div class="span-col-4"> <?php $date = $game['finish']; $newDate = ($date)?date('d F Y', strtotime($date)):''; ?> <div class="details_grid"> <div class="details_title text-shadow box-shadow">ID</div> <div class="details_answer text-shadow box-shadow"><?php echo $game['id']; ?></div> <div class="details_title text-shadow box-shadow">Year of Release</div> <div class="details_answer text-shadow box-shadow"> <a class='knil' href="year.php?id=<?php echo $game['release_year']; ?>"> <?php echo $game['release_year']; ?> </a> </div> <div class="details_title text-shadow box-shadow">Genre</div> <div class="details_answer text-shadow box-shadow"> <a class='knil' href='genre.php?id=<?php echo $game['genre']; ?>'> <?php echo $game['genre']; ?> </a> </div> <div class='details_title text-shadow box-shadow'>Series</div> <div class="details_answer text-shadow box-shadow"> <a class='knil' href='series.php?id=<?php echo $game['series']; ?>'> <?php echo $game['series']; ?> </a> </div> <div class="details_title text-shadow box-shadow">Completed Date</div> <div class="details_answer text-shadow box-shadow"> <?php if($newDate !== "") { echo "<a class='knil' href='complete.php'> {$newDate}</a>"; } ?> </div> <div class="details_title text-shadow box-shadow">High Score</div> <div class="details_answer text-shadow box-shadow"> <?php if($game['high'] !=="") { echo "<a class='knil' href='high.php'> {$game['high']}</a>"; } ?> </div> <div class="details_title text-shadow box-shadow">Platform</div> <div class="details_answer text-shadow box-shadow"> <a class='knil' href='platform.php?id=<?php echo $game['platform']; ?>'> <?php echo $game['platform']; ?> </a> </div> <div class="details_title text-shadow box-shadow">Launcher</div> <div class="details_answer text-shadow box-shadow"> <?php if($game['launcher'] !=="") { echo "<a class='knil' href='launcher.php'> {$game['launcher']}</a>"; } ?> </div> <div class="details_title text-shadow box-shadow">Achievements</div> <div class="details_answer text-shadow box-shadow"> <?php if($game['achieve'] !=="") { echo "<a class='knil' href='achieve.php'> {$game['achieve']}</a>"; } ?> </div> <div class="details_title text-shadow box-shadow">Achievements Got</div> <div class="details_answer text-shadow box-shadow"> <?php if($game['won'] !=="") { echo "<a class='knil' href='won.php'> {$game['won']}</a> "; } ?> </div> </div> </div> </div> <div></div> <div class="span-col-3 text text_center box-shadow"><?php include 'includes/footer.php'; ?></div> </body> </html> That is the code for details page, it gets the game name from another page id=xx
  2. The high is from another box . I have added an image of what i what to see when i run the page. When i add the above code to my page i get an error 'syntax error, unexpected token "if", expecting "," or ";"' I only want the link to show if there is anything in the db from that column
  3. What should happen is the if the 'high' is blank then not show the link, else show link <div class="details_title text-shadow box-shadow">Series</div> <div class="details_answer text-shadow box-shadow"> <?php if($game['series'] !== "") { echo "<div/>"; }else { echo "<a class='knil' href='series.php?id={$game['series']}></a>"; } ?> </div> <div class="details_title text-shadow box-shadow">Completed Date</div> <div class="details_answer text-shadow box-shadow"> <?php if($newDate !== "") { echo "<a class='knil' href='complete.php'> {$newDate}</a>"; } ?> With this code it does not show the divs after the link.
  4. <?php if($game['series'] !== "") { echo "<a class='knil' href='series.php?id={$game['series']}>{$game['series']}</a>"; } ?> <?php if($game['series'] !== "") { echo "<a class='knil' href='series.php?id={$game['series']}>{$game['series']}</a>"; } else { echo ""; } ?> also swapped the echo's around but still get the same result
  5. Thank you for that. now because I only want to show the link if there is one I have tried using else but does not work it stops the next div from showing on screen
  6. I have a link that i would like to become dynamic if the column is not blank i have used this code but can not get it to work. <?php if($game['high'] !=="") { echo "<a class='knil' href='high.php?id=' .{$game['high']} . '> {$game['high']}</a>"; } ?> How can i get this to work?
  7. I have made a database with my game collection. I have got an index page with all games on and made a dynamic link to take me to the 'details.page' which gets all the information from that particular game that clicked on and then it gets all the information into boxes and I have made a link for the year of release for the game and when I click this it shows all the games from that year (I added the year to the database in varchar in the format 1999). and then I tried to move on the next link which is Genre and i did the same in the database entered it as varchar, so for example 'Shooter' but when I click on this link and use the same code as I did with the year page I get an error 'Unknown column 'Shooter' in 'where clause' This is the link. <a class='knil' href='genre.php?id=<?php echo $game['genre']; ?>'> So on my genre page I have used at the top of the page. <?php include 'includes/config2.php'; $id = $_GET['id']; When I echo this out I get the right answer. But when I try to get all the games that have 'Shooter' in the genre column I get the error from above by using the following $sql = "SELECT * FROM games WHERE genre = $id"; $res = $db->query($sql) or die($db->error); while ($row = $res->fetch_assoc()) { // echo $row['game']; echo "<div class='picture bottom_margin'><img class='img' src='images/" . $row['image_name'] ."'> <div class='top-margin'></div> <div class='text text-shadow box-shadow bottom_margin text_center'> <a class='knil' href='details.php?id={$row['id']}'</a>{$row['game']}</a> {$row['id']} </div></a> </div> "; } In the $sql line if i change the $id to 'Shooter' I get all the games but would like to be able to get link I clicked. I know some of this code may not be the best, but this is a personal project and will not be going on the internet, Just trying to learn as I go along.
  8. Ok in my search bar I am trying to search my database for all the items that have "Sniper Elite" in the database so I type "Sniper Elite" into the search box and click the search button php echo's out the result like Sniper (should be Sniper Elite) Sniper (should be Sniper Elite V2 Remastered) Sniper (should be Sniper Elite III) Sniper (should be Sniper Elite 5) How can I make it echo out the full name? AS the examples are only allowing me to search one word. <?php include('includes/config.php'); ?> <form method="POST" action=""> <input class="search_bar" type="text" name="search" placeholder="Search"/> <button type="submit" name="submit-search">Search</button> </form> <?php if (isset($_POST['submit-search'])) { $search = mysqli_real_escape_string($db, $_POST['search']); $sql = "SELECT * FROM games WHERE game LIKE '%$search%'"; $result = mysqli_query($db, $sql); $queryResult = mysqli_num_rows($result); if ($queryResult > 0) { while ($row = mysqli_fetch_assoc($result)) { echo "<div> <div> <input type='text' name='game' value={$row['game']} '> </div> </div> "; } } else "There are no results matching your search"; } ?>
  9. When I type in the search box above "Manchester University" it only echo's out "Manchester" and I have other fields with the word "Manchester" in so it only shows "Manchester" and not anything if there is a space after the first word.
  10. I tried that and still just echo's out "manchester" and not the university part of the search, and if there are more then one manchester items it will show manchester and not anything after the space
  11. <form method="POST" action=""> <input class="search_bar" type="text" name="search" placeholder="Search"/> <button type="submit" name="submit-search">Search</button> </form>
  12. I have a got a search bar to look through my database If I enter say "Manchester University" in the search bar it only display's "Manchester", How do I make the the code below search multiple words if (isset($_POST['submit-search'])) { $search = mysqli_real_escape_string($db, $_POST['search']); $sql = "SELECT * FROM games WHERE game LIKE '%$search%'"; $result = mysqli_query($db, $sql); $queryResult = mysqli_num_rows($result); if ($queryResult > 0) { while ($row = mysqli_fetch_assoc($result)) {
  13. Thank I got the @mac_gyvercode to work thanks
  14. Could you tell me what I need to add in my Select query, I have tried all the arrays from your code and can not get to the second page $getQuery = "SELECT * FROM games LIMIT $total_pages, $limit";
  15. I have tried the @mac_gyver code Now I cannot get the next 12 when I press the number 2
  16. That is the problem with the for statement how do i do that
  17. I am using a grid system . And the code works but i can not get it not to show the full 261 buttons as the code to show the buttons will show all <?php echo "<div class='pagination'>"; for($page_number = 1; $page_number<= $total_pages; $page_number++) { echo '<a href = "home3.php?page=' . $page_number . '">' . $page_number . ' </a></div>'; } ?> it shows 113 114 etc. <div class="wrapper"> <div class="span-col-4"><img src="images/logo2.png"></div> <div class="span-col-4"><?php include 'includes/navbar.php'; ?></div> <div class="span-col-4"><?php include 'includes/a-z.php'; ?></div> <div class="span-col-4"> <!--- Pagination code goes here ---></div> <?php $getQuery = "SELECT * FROM games LIMIT $initial_page, $limit"; $result = mysqli_query($db,$getQuery); while ($row = mysqli_fetch_array($result)) { echo "<div class='picture'><img class='img' src='images/" . $row['image'] ."'> <div class='text text-shadow box-shadow'>{$row['game']}</div> </div>"; } ?> <?php echo "<div class='pagination'>"; for($page_number = 1; $page_number<= $total_pages; $page_number++) { echo '<a href = "home3.php?page=' . $page_number . '">' . $page_number . ' </a></div>'; } ?> here is the code for the page |Logo| |Nav bar| |a-z| |image 1| |image 2| |image 3| |image 4| |1| |2| |3|
  18. Sorry what i meant was how do i add each text under the image to go to another page?
  19. As it now works and I get 12 images, I have two more questions. 1.. how do i stop the code below showing all 261 buttons for($page_number = 1; $page_number<= $total_pages; $page_number++) { echo '<a href = "home3.php?page=' . $page_number . '">' . $page_number . ' </a>'; 2. how do i also get text below the images with the follow code? <a href="details.php?id=<?php echo $row['id']?>">
  20. I am trying to do pagination on my site, I have over 3,000 entries and would like the page to show 12 images per page and the code below gives me an error : Uncaught TypeError: mysqli_fetch_array(): Argument #1 ($result) must be of type mysqli_result, bool given if(!isset($_GET['page'])) { $page_number = 1; } else { $page_number = $_GET['page']; } $limit = 12; $initial_page = ($page_number-1) * $limit; $getQuery = "SELECT * FROM games"; $result = mysqli_query($db, $getQuery); $total_rows = mysqli_num_rows($result); $total_pages = ceil($total_rows / $limit) $getQuery = "SELECT * FROM games LIMIT" . $initial_page.','.$limit; $result = mysqli_query($db,$getQuery); while ($row = mysqli_fetch_array($result)) { echo $row['image']; } I have tried about 20 different tutorials on pagination and get get none to work.
  21. I have got four images side by side and would like to have the name of the image below, but when i try the following code it puts the text of the image next to the image <div> <?php foreach($games as $game): ?> <?php echo "<img class='img' src='images/" . $game['image'] ."' >"?> <?php echo $game['game']?> <?php endforeach; ?> </div>
  22. i have a grid container with the following sizes .container { display: grid; grid-template-columns: 200px 1200px 420px; gap: 10px; } .row { border: 1px solid aliceblue; border-radius: 5px; background-clip: border-box; position: relative; background-color: darkslategrey; } In the middle grid i want to add 4 images of 400x225 side by side. how do i do this please
  23. How do i do this with php code as i tried the above code and it did not work
  24. I have a list of images that i show on screen in and what to be able to click on the image and have it go to another page, I can do this with text but not an image <?php echo "<img class='img_two' src='images/" . $game['image'] ."' >"?> This is the code that just shows the images, i have tried the following <a href="details.php?id=<img class='img_two' src='images/" . <?php echo $game['image'] ?> But does not show anything Please Help
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.