I am trying to show people their profiles from my database using PHP. But every time a button is clicked I want the person_id ($which_person) to go up by 1 so the next person's profile is shown. I don't know how to do that because every time I click a button the page reloads so the variable "which_person" gets reset to 1.
    <!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 href="assets-putinhouse/css/style1.css" rel="stylesheet" type="text/css">
            <link rel="preconnect" href="https://fonts.googleapis.com">
            <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
            <link href="https://fonts.googleapis.com/css2?family=Festive&display=swap" rel="stylesheet">
            <title>Put people in a house</title>
        </head>
        <body>
            <?php
               include "db/connection.php"; 
               $conn = create_connection();
               $which_person = 1; //This resets to "1" every time the page reloads
    
               $getSql = "select * from Person where person_id = 1;";
               $data_labels = mysqli_query($conn, $getSql)->fetch_all(MYSQLI_ASSOC);
            ?>
    
            <div class="pagesize">
                <h1>Put people in a house</h1>
                <img src="assets-putinhouse/images/create_account.png" alt="profilepic" class="image_person">
                <?php
                    foreach($data_labels as $labels)
                {
                ?>
                    <li class="labels" data-id="<?php echo $labels['person_id'];?>">
                        <?php echo $labels["firstname"] ?>
                        <br>
                        <br>
                        <?php echo $labels["secondname"] ?>
                        <br>
                        <br>
                        <?php echo $labels["gender"] ?>
                        <br>
                        <br>
                        <?php echo $labels["descriptie"] ?>
                    </li>
                <?php
                }
                ?>
                <br>
                <form method="GET">
                <input type="submit" class="slytherin_button" value="Slytherin" name="slytherin_button_name">
                <br>
                <input type="button" class="gryffindor_button" value="Gryffindor"  name="gryffindor_button_name">
                <br>
                <input type="button" class="hufflepuff_button" value="Hufflepuff"  name="hufflepuff_button_name">
                <br>
                <input type="button" class="ravenclaw_button" value="Ravenclaw"  name="ravenclaw_button_name">
                <br>
                <input type="button" class="nextperson_button" value="Go to next person">
    
                <p class="text_firstname">Firstname: </p>
                <p class="text_name">Name: </p>        
                <p class="text_gender">Gender: </p>   
                <p class="text_info">Info: </p>   
    
    
    
                <?php
                if(isset($_GET['slytherin_button_name'])) {
                    onFunc($conn, $which_person);
                }
                if(isset($_GET['gryffindor_button_name'])) {
                    offFunc();
                }
                function onFunc($conn, $wich_person){
                    $sqlUpdate = "UPDATE Person SET slytherin = slytherin + 1  WHERE person_id like '$which_person';"; //this does the value "slytherin" of which_person go up by 1;
                    mysqli_query($conn, $sqlUpdate);
                    $wich_person = $wich_person + 1; //which person goes up by 1 so the next person will be shown but gets reset at the start
                }
                function offFunc(){
                    echo "Button is clicked";
                }
                ?>
            </div>
            <script src="assets-putinhouse/js/script.js"></script>
        </body>
    </html>
´´´
 
     
    