1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| <?php
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
$sql = "SELECT * FROM myTable";
$result = $conn->query($sql);
while($row = mysqli_fetch_array($result))
{ ?>
<?php echo '<div id="'.$row["urlName"].'content">'; ?>
<ul>
<li>
<div class="item">
<div class="text-content">
<h4><?php echo $row["title"] ?>
<div id="description1" style="display:none"><?php echo '<p>'.$row["description1"].'</p>'; ?></div>
<div id="description2" style="display:block"><?php echo '<p>'.$row["description2"].'</p>'; ?></div>
<label class="switch">
<input type="checkbox" onclick="change()">
<span class="slider round">
<h1 id="light-text" style="display:none">ON</h1>
<h1 id="on" style="position:relative;left:-85px;bottom: 25px;font-size:18px;">On</h1>
<h1 id="off" style="position:relative;left:70px;bottom: 65px;font-size:18px;">OFF</h1>
</span>
</label>
</div>
</div>
</li>
</ul>
</div>
<?php }
$conn->close();
?>
<script>
function change() {
var x = document.getElementById("light-text");
var measurementImperial = document.getElementById("measurementImperial");
var measurementMetric = document.getElementById("measurementMetric");
if (x.innerHTML === "Metric") {
x.innerHTML = "Imperial";
measurementImperial.style.display = "block";
measurementMetric.style.display = "none";
} else {
x.innerHTML = "Metric";
measurementImperial.style.display = "none";
measurementMetric.style.display = "block";
}
}
</script> |
Partager