Hallo,

Via MySQL DB waar nieuwsberichten in bewaard worden wil ik deze laten verschijnen op het scherm als deze geactiveerd worden. Dit lukt mij en krijg het eerste bericht te lezen. Nu wil ik meerdere berichten activeren in het volgende script...

1. PHP script oproep nieuwsberichten

<?php

$sql = "SELECT * FROM BreakingNews WHERE Activatie = '1'";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {

//$ResultQuotes = "... " . $row["Titel"]. " ...<br>";
//printf ("%s (%s)\n", $row["Titel"], $row["Nieuws"]);
printf ("%s %s ", $row["Titel"], $row["Nieuws"]);

$ResultBreakingNews_Titel = $row["Titel"];
$ResultBreakingNews_Nieuws = $row["Nieuws"];


}
} else {
echo "0 results";
}

mysqli_free_result($result);

?>

2. HTML script zichtbaar maken nieuwsberichten


<html>
<body>


<div class="row py-2">
  <div class="col-2 col-sm-1 col-md-3 col-lg-2 py-1 pe-md-0 mb-md-1">
    <div class="d-inline-block d-md-block bg-primary text-white text-center breaking-caret py-1 px-2">
      <svg xmlns="http://www.w3.org/2000/svg" width="1rem" height="1rem" fill="currentColor" class="bi bi-lightning-fill" viewBox="0 0 16 16">
        <path d="M11.251.068a.5.5 0 0 1 .227.58L9.677 6.5H13a.5.5 0 0 1 .364.843l-8 8.5a.5.5 0 0 1-.842-.49L6.323 9.5H3a.5.5 0 0 1-.364-.843l8-8.5a.5.5 0 0 1 .615-.09z"/>
      </svg>
      <span class="d-none d-md-inline-block">Breaking news</span>
    </div>
  </div>

  <!--Breaking content-->
  <div class="col-10 col-sm-11 col-md-9 col-lg-10 ps-1 ps-md-2">
    <div class="breaking-box pt-2 pb-1">
      <!--marque-->
      <marquee behavior="scroll" direction="left" onmouseover="this.stop();" onmouseleave="this.start();">
  
        <span class="position-relative mx-2 badge bg-primary rounded-0"><?php echo $ResultBreakingNews_Titel ?></span><?php echo $ResultBreakingNews_Nieuws ?>
        <span class="position-relative mx-2 badge bg-primary rounded-0">Title 2</span> News 2
        <span class="position-relative mx-2 badge bg-primary rounded-0">Title 3</span> News 3
        <span class="position-relative mx-2 badge bg-primary rounded-0">Title 4</span> News 4
        <span class="position-relative mx-2 badge bg-primary rounded-0">Title 5</span> News 5
      	
        
      </marquee>
    </div>
  </div>
</div>


</body>
</html>


Hoe kan ik dit allemaal verwerken in een LOOP beweging :


<html>
<body>

<span class="position-relative mx-2 badge bg-primary rounded-0"><?php echo $ResultBreakingNews_Titel ?></span><?php echo $ResultBreakingNews_Nieuws ?>


</body>
</html>
Kun je jouw script tussen code tags plaatsen? Dan is het beter leesbaar.

Reageren