Jump to content

Revolutsio

Members
  • Posts

    85
  • Joined

  • Last visited

About Revolutsio

  • Birthday 10/15/1969

Profile Information

  • Gender
    Male
  • Location
    Manchester, UK

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Revolutsio's Achievements

Regular Member

Regular Member (3/5)

1

Reputation

  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
×
×
  • 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.