Hallo Leute, mein Code sollte eigentlich mit Hilfe einer While-Schleife einige Überschriften ausgeben. Leider passiert bei mir nicht. Vielleicht findet ja von euch einer einen Fehler im Code.
Der Code für die MySQL Connection:
Der Code:
Vielen dank schon mal für euer Hilfe.
Der Code für die MySQL Connection:
PHP-Code:
$mysql_host = "***";
$mysql_username = "***";
$mysql_password = "***";
$mysql_database = "***";
$pdo = new PDO("mysql:host=".$mysql_host.";dbname=".$mysql_database, $mysql_username, $mysql_password);
PHP-Code:
<?php
$getCategory_STATEMENT = $pdo->prepare("SELECT * FROM productitem WHERE active = true");
$getCategory_STATEMENT->execute();
while($rowPC = $getCategory_STATEMENT->fetch()) {
if($rowPC['active'] == "true") {
?>
<div class="ProductCategory">
<!-- ProductCategory -->
<h1 class="ProductCategoryH1"><u><?php echo $rowPC['name']; ?></u></h1>
<div class="row">
<?php
$getItemsInCategory = $pdo->prepare("SELECT * FROM productitem WHERE ProductCategoryID = :pid");
$getItemsInCategory->bindParam("pid", htmlspecialchars(trim($rowPC['id'])));
$getItemsInCategory->execute();
while($rowPI = $getItemsInCategory->fetch()) {
if($rowPI['active'] == "true") {
?>
<div class="col-sm">
<div class="ProductItem bg-info">
<img class="ProductItem_IMG" src="<?php echo $rowPI['small_icon']; ?>" alt="ProductImage">
<div class="card-body">
<h5 class="product-title"><b><?php echo $rowPI['name']; ?></b></h5>
<p><?php echo $rowPI['short_description']; ?></p>
<?php
if($rowPI['forFree'] == "true") {
echo '<p style="margin-bottom: 0;"><a href="#" class="btn btn-warning"> <b>ansehen</b> </a> <span class="product-price_free">  <b>FREE €</b>  </span></p>';
} else {
echo '<p style="margin-bottom: 0;"><a href="#" class="btn btn-warning"> <b>ansehen</b> </a> <span class="product-price">  <b>' . $rowPI['price'] . ' €</b>  </span></p>';
}
?>
</div>
</div>
</div>
<?php
}
}
?>
</div> <!-- ROW END -->
</div> <!-- ProductCategory END -->
<?php
Vielen dank schon mal für euer Hilfe.
Kommentar