0

I have a table of 1400+ rows and adding approx 20 everyday getting my page slow

I am using while loop to generate table rows and columns and also some JS like this

<?php
$cp=0
while($row=mysqli_fetch_array($rs)){
        $cp++;
        $editid = $row['id'];   
       $ccperson = $row['cperson'];
?>
        <tr>
        <td span id="cperson<?php echo $cp;?>"><?php echo $ccperson;?></span></td>
        <Input id="cperson_input<?php echo $cp;?>" style="display:none"/>
       <script type="text/javascript">
        // On double click show the input box
$( "#cperson<?php echo $cp;?>" ).dblclick(function() {
    getsetEdit('<?php echo $cp;?>','<?php echo $editid;?>', 'cperson');
    });
</script>
<?php
</tr>
}
?>

Is it possible to get it done on a fly?

phi lo czar
  • 349
  • 2
  • 12
ehsanonyx
  • 9
  • 2
  • 1
    **WARNING**: It is extremely important to **NEVER** accept arbitrary query strings from the user and just run them. Find some other way to do this where you screen the input carefully, such as in checking versus a white-list of allowed values. – tadman Jun 17 '19 at 16:46
  • [Bobby Tables](https://bobby-tables.com/) – devlin carnate Jun 17 '19 at 16:50
  • If you want to do this, then read [How can I prevent SQL injection in PHP?](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php). – filipe Jun 17 '19 at 17:20
  • Also read [jQuery Ajax POST example with PHP](https://stackoverflow.com/questions/5004233/jquery-ajax-post-example-with-php). – filipe Jun 17 '19 at 17:23

1 Answers1

1

Of course your page has to slow down with time. This is because data increases with time (20 every day). Loading a bunch of data will lead to slow processing time or even collapse the browser. What you are looking for is called pagination. it is loading of data in steps. You might have seen on facebook that after scrolling down, more data is loaded. This is to avoid the problem you are experiencing. Research about pagination.You can then use AJAX JQUERY AND PHP to make it happen on fly.

phi lo czar
  • 349
  • 2
  • 12