coeragames

Untitled

Jun 16th, 2021
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['page']) && !empty($_POST['page'])) {
  4. $load_min = 15 * $_POST['page'];
  5. $load_max = 15 * $_POST['page'] + 15;
  6. }
  7. else {
  8.  
  9. $load_min=0
  10. $load_max=15
  11. }
  12.  
  13. try
  14. {
  15. $bdd = new PDO('mysql:host=127.0.0.1;dbname=test', 'root', '');
  16. }
  17. catch (Exception $e)
  18. {
  19. die('Erreur lors de la connection à la base de données, veuillez nous excuser.');
  20. }
  21. $req = $bdd->prepare('SELECT id, titre, contenu, temps, redacteur FROM news ORDER BY id DESC LIMIT :nb_min, :nb_max');
  22. $req->execute(array(
  23. 'nb_min' => $load_min,
  24. 'nb_max' => $load_max
  25. ));
  26.  
  27. while($news = $req->fetch())
  28. {
  29. ?>
  30.  
  31. <div class="notification is-info is-light">
  32. <h2 class='title is-2'><?php echo $news['titre'] ?></h2><br><br>
  33. <p><?php echo $news['contenu'] ?></p><br><br>
  34. <i>Par <?php echo $news['redacteur'] ?> | <?php echo $news['temps'] ?></i>
  35. </div>
  36. <br><br>
  37.  
  38. <?php
  39.  
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment