Fixed catalog using while and not foreach, since now we will grab shit from sql.
This commit is contained in:
parent
e417fde7c1
commit
8debbbf68f
50
catalog.php
50
catalog.php
|
|
@ -62,12 +62,12 @@ $getitstarted->header();
|
|||
</ul>
|
||||
<li class="list-group-item">
|
||||
<h5>Legend</h5>
|
||||
<span class="badge bg-success" style="width: 3.5rem;">Limited</span>
|
||||
<span class="badge bg-success" >Limited</span>
|
||||
<br>
|
||||
<p class="text-white">Limited Items </p>
|
||||
<p>Owners of these discontinued items can re-sell them to other users at any price.</p>
|
||||
<div class="pt-2"></div>
|
||||
<span class="badge bg-success" style="width: 4.5rem;">Limited <span class="badge bg-danger" style="width: 1.1rem;">U</span>
|
||||
<span class="badge bg-success">Limited <span class="badge bg-warning text-dark">U</span>
|
||||
</span>
|
||||
<br>
|
||||
<p class="text-white">Limited Unique Items</p>
|
||||
|
|
@ -80,27 +80,36 @@ $getitstarted->header();
|
|||
$q = $con->prepare(str_replace('allStar', 'count(*)', $sql));
|
||||
$q->execute();
|
||||
$numberOfItems = $q->fetchColumn();
|
||||
$sql = "SELECT allStar FROM catalog LIMIT :limit OFFSET :offset";
|
||||
$page = $_GET['p'] ?? 0;
|
||||
$limit = 20;
|
||||
$lpage = $limit*$page;
|
||||
$q = $con->prepare(str_replace('allStar', '*', $sql));
|
||||
$q->bindParam(':limit', $limit, PDO::PARAM_INT);
|
||||
$q->bindParam(':offset', $lpage, PDO::PARAM_INT);
|
||||
$q->execute();
|
||||
if ($numberOfItems >= 1) {
|
||||
while ($item = $q->fetch()) {
|
||||
$qq = $con->prepare("SELECT * FROM users WHERE id = :id");
|
||||
$qq->bindParam(':id', $item["creator"], PDO::PARAM_INT);
|
||||
$qq->execute();
|
||||
$creator = $qq->fetch();
|
||||
if(!$creator) {
|
||||
$creator = [
|
||||
foreach ($q->fetchAll() as $item) {
|
||||
$query = $con->prepare('SELECT COUNT(id) FROM users WHERE id=:id');
|
||||
$query->bindParam(':id', $_SESSION['user'], PDO::PARAM_INT);
|
||||
$query->execute();
|
||||
$userExists = $query->fetchColumn();
|
||||
if($userExists <= 1) {
|
||||
$creator = [
|
||||
"id" => $_SESSION['user'],
|
||||
"username" => $item["name"]
|
||||
];
|
||||
} else {
|
||||
$creator = [
|
||||
"id" => 0,
|
||||
"username" => "[ unknown user ]"
|
||||
];
|
||||
}
|
||||
$x = 40;
|
||||
for ($i = 1; $i <= $x; $i++) {
|
||||
];
|
||||
}
|
||||
?>
|
||||
<div class="position-relative col">
|
||||
<div class="card shadow-sm h-100">
|
||||
<a href="item.php?id=<?php echo (int)htmlspecialchars($item["id"]); ?>"><img src="<?php if (!empty($item["thumbnail"])) {echo htmlspecialchars($item["thumbnail"]);} else {echo "assets/placeholder.png";} ?>" class="card-img-top"></a>
|
||||
<p class="me-1 mt-1 position-absolute top-0 end-0"><?php if(rand(1, $x) == $x) { echo '<span class="badge bg-success">Limited</span>'; }; ?></p>
|
||||
<div class="card shadow-sm h-100 d-inline-block">
|
||||
<a href="item.php?id=<?php echo (int)htmlspecialchars($item["id"]); ?>"><img src="<?php if (!empty($item["thumbnail"])) {echo htmlspecialchars($item["thumbnail"]);} else {echo "assets/placeholder.png";} ?>" height=150 width=150 class="card-img-top"></a>
|
||||
<p class="me-1 mt-1 position-absolute top-0 end-0"><?php if($item['limited'] == 1) { echo '<span class="badge bg-success">Limited</span>'; }; ?></p>
|
||||
<span class="fs-6 mt-2 ms-2 opacity-75 position-absolute top-50 start-0 translate-middle-y bg-success badge">$<?php echo (int)htmlspecialchars($item["price"]); ?></span></img>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo htmlspecialchars($item["name"]); ?></h5>
|
||||
|
|
@ -111,16 +120,11 @@ $getitstarted->header();
|
|||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if ($i == $x) {
|
||||
break;
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} } else {
|
||||
echo "</div> <h4 class='text-muted text-center'><i class='bi bi-egg-fried' style='font-size: 6rem;'></i><br> Looks like there are no items in the catalog yet...</h4>";} ?>
|
||||
<br>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue