0

I have multiple databases of videos that I want to display in an HTML page with four columns. The database would look like this: DATABASE example

Since there are only four columns on the HTML page I need to pull 25% of the rows at a time from the database to put into each column. So if there are 100 videos in a database then there should be 25 videos in each column on the HTML page.

The HTML page would look like this: HTML example

Here is the code I have so far. This prints out every video in the database into the first column. I am not sure the best way to make it stop printing after the first 25% of rows. Once I get that figured out, then how do I start the second column where the first left off and so on?

        <div class="row">

            <!-- FIRST COLUMN -->
            <div class="col-md-3">
                <ul class="simple">
                    <?php

                        // GET ROW COUNT
                        $queryCount = 'SELECT COUNT(*) AS count FROM `video_db1`';
                        $responseCount = mysqli_query($conn, $queryCount);
                        while ($rowCount = mysqli_fetch_assoc($responseCount)) {
                            $outputCount = $rowCount['count'];
                        }

                        // OUTPUT ROW COUNT TO SEE IF ITS WORKING
                        $outputCount = round($outputCount / 4);
                        echo $outputCount;
                        
                        // SELECT ROWS FROM DATABASE
                        $queryCode = 'SELECT * FROM video_db1 ORDER BY video_id ASC';
                        $responseCode = mysqli_query($conn, $queryCode);
                        if ($responseCode) :
                            if (mysqli_num_rows($responseCode) > 0) :
                                while ($video = mysqli_fetch_assoc($responseCode)) :
                                    echo $video['video_id'];
                    ?>
                    <?php
                                endwhile;
                            endif;
                        endif;
                    ?>
                </ul>
            </div>

            <!-- SECOND COLUMN -->
            <div class="col-md-3">
                <ul class="simple">

                </ul>
            </div>

            <!-- THIRD COLUMN -->
            <div class="col-md-3">
                <ul class="simple">

                </ul>
            </div>

            <!-- FOURTH COLUMN -->
            <div class="col-md-3">
                <ul class="simple">

                </ul>
            </div>
        </div>

0 Answers0