Jump to content

Revolutsio

Members
  • Posts

    85
  • Joined

  • Last visited

Posts posted by Revolutsio

  1. 15 hours ago, dodgeitorelse3 said:

    How about showing all the code that pertains to this issue? You may have a clear idea what you have tried and want but you are making us pick through incomplete information which is wasting our time.

    <?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. 51 minutes ago, ginerjm said:

    Your code says if 'series' is NOT blank don't show a link.

    Then your code says if newdate is not blank show a link.

    I have no idea what your reference to 'high' is in this conversation for.  And frankly I really don't know what you are trying to tell us.

    Take a look at this code and play with the values to see what happens.  See how I kept it in php mode to make it easier to code?

    $game['series'] = '';
    $newDate = '';
    echo "
    	<div class='details_title text-shadow box-shadow'>Series</div>"
    if($game['series'] == "")
    	echo "<div class='details_answer text-shadow box-shadow'>
    		<a class='knil' href='series.php?id={$game['series']}'></a></div>";
    
    echo '<div class="details_title text-shadow box-shadow">Completed Date</div>';
    if($newDate !== "")
    	echo "<div class='details_answer text-shadow box-shadow'>
    		<a class='knil' href='complete.php'>$newDate</a></div>";

    See how I re-arranged your interior div tags?

    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

    Screenshot 2022-06-30 174631.png

  3. 1 hour ago, Barand said:

    Perhaps because there apparently is no code to show another div?

    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. 9 minutes ago, dodgeitorelse3 said:

    Please show what you tried.

    Quote

     

    <?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. 21 hours ago, ginerjm said:

        echo "<a class='knil' href='high.php?id={$game['high']}'>{$game['high']}</a>";
     

    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. 44 minutes ago, mac_gyver said:

    what exactly is the "it only display's" and "still just echo's" code that you are describing that is not working?

    also, you should use a get method form for searching and determining what data will be gotten and displayed on a page and the form should be 'sticky' so that it remembers what the existing search term is in case the user wants to just modify the search value and try again. doing this will be a necessity if your next step is to combine the search feature with the pagination from your last thread.

    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 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)) {

     

  11. 19 hours ago, mac_gyver said:

    wouldn't that mean that you need to investigate why it isn't working in order to find and fix what's causing the incorrect operation?

    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";

     

  12. 17 hours ago, cyberRobot said:

    Have you considered using a CSS grid layout? A quick example can be found here:
    https://css-tricks.com/how-do-you-make-a-layout-with-pictures-down-one-side-of-a-page-matched-up-with-paragraphs-on-the-other-side/

    A more in-depth description of grid layouts can be found here:
    https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout

     

    Side note: the <center> tag mentioned in an earlier post should be avoided since it has been deprecated (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center). CSS is usually the way to go when changing how something visually appears on the page.

    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|
    
    

     

  13. 12 minutes ago, ginerjm said:

    If I read  you correctly, you want to make sure that the anchor tag is located below the image?  Each image and text should be output inside of a div tag and you can position each pair as you like inside of that.   Perhaps something like:

    <div>
    <img>
    <br>
    <center>
    anchor
    </center>
    </div>

    Repeat that block of code for each image you wish to appear.

    As for the 261 images, don't know what you are referring to.  But if it is because you are involved in the pagination here, then keep track of what id you are querying for and start your output loop with that value and only go for that number plus you limit value. 

    Sorry what i meant was how do i add each text under the image to go to another page?

  14. 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']?>">

     

  15. 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.

  16. 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>

     

  17. 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

  18. 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.