'ajax load method and a while loop appears to only return 1 row

So i am calling a load method in ajax on my table.

<?php
    include_once "inc/Header.php";


?>

<body>
    <head>
        <link rel="stylesheet" href="inc/bootstrap.min.css">

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
        <script>
            $(document).ready(function(){
                var packslimit=5;
                $(".dudewtf").click(function(){
                    packslimit += 5;
                    alert("sxdsa");
                    $("#unrealpacks2").load("inc/loadunrealpacksinc.php", {"newlimit":packslimit});
                });
            });

        </script>
    </head>

    <h1 style="text-align:center;">Free Unreal Packs</h1>

    <div style="padding-bottom:70px;padding-top:40px;text-align:center;">

        <a href="CreatePack.php" class="btn btn-default">Create</a>
    </div>

    <table class="table table-striped table-hover" id="unrealpacks2">
        <!-- <tr>
            <th>Asset Name</th>
            <th>Asset Description</th>
            <th>Asset Url</th>
            <th>Asset Uploader</th>
        </tr> -->

        <?php
            include_once "classes/dbh.class.php";
            include_once "classes/UnrealPacks-view.class.php";
            $limit = 5;
            $view = new UnrealPacksView();
            $view->GetAllUnrealPacks($limit);

        ?>
        


    </table>
    <div style="text-align:center;">
    <button class="dudewtf">Load More</button>
    </div>


    
</body>

above is the ajax call.

 public function GetAllUnrealPacks($limit)
    {
        
        $results = $this->GetUnrealPacks($limit);

        include_once "login.class.php";


        echo "<tr>
            <th>Asset Name</th>
            <th>Asset Description</th>
            <th>Asset Url</th>
            <th>Asset Uploader</th>
        </tr>"; 
        echo $results->rowCount();

        
        while ($row = $results->fetch())
        {        
            echo 'hello';
            echo "<tr>";
            echo "<td>" . $row['AssetName'] . "</td>";
            echo "<td>" . $row['AssetDescription'] . "</td>";
            echo "<td>";
            echo "<a class='btn btn-default' href=";
            echo "'";
            echo $row['AssetUrl'];
            echo "'";
            echo ">";
            echo "Link";
            echo "</a>";
            echo "</td>";
            

            if ($id = $this->getUserById($row['playerid']))
            {
                
                echo "<td>";
                echo "<a class='btn btn-default' href=";
                echo "''";
                echo $id;
                echo "''";               
                echo ">";
                echo $id;
                echo "</a>";
                echo "</td>";
            }else {
                echo "<td>Creator Not Found!</td>";
            }
            
            
            echo "</tr>";
        }
    }

this is the while loop function that it's going to. It is only getting the first entry

also this below

$sql = "SELECT * FROM unrealpackstable LIMIT $limit;";

is the sql statement i am using. the $limit variable is parameter.

I know that this isn't a duplicate id on my html...please anyone tell me why it's not iterating properly with my while loop.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source