0

My web page exceed maximum execution time of 300 seconds as I adjust it. Is there a way to speed up loading of my web page?

This is my code

<tbody>
    <?php
    $sql = $mysqli->query("SELECT * FROM mobile order by timestamp asc");
    if ($sql->num_rows > 0) {
        while ($row = $sql->fetch_assoc()) {
            $contactID = $row['id'];
            $contactName = $row['name'];
            $contactEmail = $row['email'];
            $contactAddress = $row['address'];
            $contactOthers = $row['others'];
            $contactNumber = $row['number']; ?>
            <tr>
                <td><?php echo $contactName; ?></td>
                <td><?php echo $contactNumber; ?></td>
                <td><?php echo $contactEmail; ?></td>
                <td><?php echo $contactAddress; ?></td>
                <td><?php echo $contactOthers; ?></td>
                <td class="td-actions text-center">
                    <a href="#edit<?php echo $contactID; ?>" data-toggle="modal">
                        <button type="button" title="Edit Contact" class="btn text-warning" style="background-color: transparent; border: none;">
                            <i class="fas fa-edit"></i>
                        </button>
                    </a>
                    <a href="#assign<?php echo $contactID; ?>" data-toggle="modal">
                        <button type="button" title="Assign to Group" class="btn text-primary" style="background-color: transparent; border: none;">
                            <i class="fas fa-object-group"></i>
                        </button>
                    </a>
                    <a href="#delete<?php echo $contactID; ?>" data-toggle="modal">
                        <button type="button" title="Delete Contact" class="btn text-danger" style="background-color: transparent; border: none;">
                            <i class="fas fa-trash-alt"></i>
                        </button>
                    </a>
                </td>
                <?php include 'xtensions/Actions/contactActions.php'; ?>
            </tr>
            <?php
        }
    }
    ?>
    </tbody>

In my MySQL Database that i am fetching rows has a 306 rows.

Lucas Meine
  • 1,524
  • 4
  • 23
  • 32
  • the problem is you're loading everything at once, try to cut the results in several pages – Kevin Nov 07 '19 at 09:13
  • 2
    Agreed with Kevin. Use [pagination](https://stackoverflow.com/questions/3705318/simple-php-pagination-script). – Andrei Nov 07 '19 at 09:13
  • 3
    **What does this do** `` – RiggsFolly Nov 07 '19 at 09:14
  • 1
    **300 seconds to load 306 rows** means there is something seriously wrong here.and it is unlikely to be the Database Access that is causing this. Pagination is unlikely to be an answer in this case! @Kevin – RiggsFolly Nov 07 '19 at 09:18
  • @RiggsFolly or probably this `` line makes an http call or an API – Kevin Nov 07 '19 at 09:20
  • Attach the full php script. Seems like there is a script consuming more time. – Rotimi Nov 07 '19 at 09:21
  • @Kevin That is the most likely place where something nasty is going on, yes. Hence I asked for the OP to show us that code :) – RiggsFolly Nov 07 '19 at 09:22
  • Thanks guys i resolved it. The problem is my jquery data table load up all of my data in my database so i use pagination. Thanks guys! :)) – Kael Jordins Nov 21 '19 at 05:43

1 Answers1

0

Your requested include is inside while loop thus is included and executed 306 times

<?php include 'xtensions/Actions/contactActions.php'; ?>

try to find a way to move it outside the loop.

George Dryser
  • 322
  • 1
  • 7