How to limit database call number on different monitors

Asked

Viewed 24 times

1

Well my problem is this, my site is configured for android and desktop, then I call the data by database and use the LIMIT ai it shows both "x", I would like to know how to use the LIMIT for desktop value "x" and for android another value, would anyone know how I could do ? here’s 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>';
  }
?>
  • at first you would have to take the user-agent through the front end, and send as a parameter to the back end, so Oce could know and process the data.

  • could you give an example? I’m a beginner

1 answer

0

With PHP it’s complicated but there’s a way.

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

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

php checks whether $_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 by going global mobile, then just check

<?php

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

...
?>

There’s no way I recommend doing this.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.