Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['page']) && !empty($_POST['page'])) {
- $load_min = 15 * $_POST['page'];
- $load_max = 15 * $_POST['page'] + 15;
- }
- else {
- $load_min=0
- $load_max=15
- }
- try
- {
- $bdd = new PDO('mysql:host=127.0.0.1;dbname=test', 'root', '');
- }
- catch (Exception $e)
- {
- die('Erreur lors de la connection à la base de données, veuillez nous excuser.');
- }
- $req = $bdd->prepare('SELECT id, titre, contenu, temps, redacteur FROM news ORDER BY id DESC LIMIT :nb_min, :nb_max');
- $req->execute(array(
- 'nb_min' => $load_min,
- 'nb_max' => $load_max
- ));
- while($news = $req->fetch())
- {
- ?>
- <div class="notification is-info is-light">
- <h2 class='title is-2'><?php echo $news['titre'] ?></h2><br><br>
- <p><?php echo $news['contenu'] ?></p><br><br>
- <i>Par <?php echo $news['redacteur'] ?> | <?php echo $news['temps'] ?></i>
- </div>
- <br><br>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment