How to limit database call number on different monitors

1

Well my problem is the following, my site is configured for android and desktop, there I call the data through the database and I use LIMIT it shows both "x", I would like to know how to use LIMIT for desktop value "x" and for android other value, would anyone know how I could do it? here is a piece of my code

<?php
  $strSQL = sprintf("SELECT * FROM 'livros' WHERE limita = 'inicio' AND status = 'velho_testamento' LIMIT");
  $stmt = $mysql->execute($strSQL);
  while($row = $stmt->fetchObject()){
     echo '<li><a href="capitulos.php?id_livro='.$row->id_livro.'" class="'.$row->responsive.'">'.$row->nome_livro.'</a></li>';
  }
?>
    
asked by anonymous 04.10.2017 / 21:58

1 answer

0

With PHP is tricky but has a way.

<?php if(!isset($_GET['mobile'])) {?>
    <script>

    if(window.innerWidth < 920){
         window.location.href = "?mobile=true";
    }
    </script>
<?php } ?>

The php checks if $_GET['mobile'] exists if it does not exist, it prints a javascript code capable of capturing the width, if it is < X , redirects to the same page passing the global mobile , then just check

<?php

$limit = (isset($_GET['mobile'])) ? 10 : 30;

...
?>

I do not recommend doing this at all.

    
04.10.2017 / 22:16