Перенос отображения подарков в класс.

This commit is contained in:
Igor Barkov (iwork) 2020-07-03 19:37:24 +03:00
parent 16a2b0e5da
commit 25a6f17d7e
2 changed files with 23 additions and 18 deletions

View File

@ -6,7 +6,6 @@ class User
public $id; public $id;
public $login; public $login;
public $email; public $email;
private $pass;
public $realname; public $realname;
public $borndate; public $borndate;
public $info; public $info;
@ -41,4 +40,26 @@ class User
} }
} }
} }
public function showPresents()
{
//$presents = db::c()->query('SELECT img, sender FROM `users_presents` WHERE expiration_date >= "?s" AND owner = ?i', date('Y-m-d'), $user->id);
$presents_query = db::c()->query();
if ($presents_query->getNumRows()) {
echo <<<PRESENT_BEFORE
<div>
<legend>Подарки</legend>
PRESENT_BEFORE;
while ($row = $presents_query->fetch_assoc()) {
echo <<<PRESENT
<img src = "{$row['img']}" title = "{$row['sender']}" alt = "{$row['sender']}" >
PRESENT;
}
echo <<<PRESENT_AFTER
</div>
PRESENT_AFTER;
}
}
} }

18
inf.php
View File

@ -22,13 +22,6 @@ function private_access($uid)
return false; return false;
} }
//$presents = db::c()->query('SELECT img, sender FROM `users_presents` WHERE expiration_date >= "?s" AND owner = ?i', date('Y-m-d'), $user->id);
function getnumrows()
{
}
$presents = [];
if (empty($user->id)): ?> if (empty($user->id)): ?>
<!doctype html> <!doctype html>
<html lang="ru"> <html lang="ru">
@ -86,16 +79,7 @@ if (!empty($user->realname)) {
?> ?>
<p style="font-family: Consolas,monospace;"><?= nl2br($user->info) ?></p> <p style="font-family: Consolas,monospace;"><?= nl2br($user->info) ?></p>
<hr> <hr>
<?php if ($presents->getNumRows()): ?> <?php $user->showPresents(); ?>
<div>
<legend>Подарки</legend>
<?php
while ($row = $presents->fetch_assoc()): ?>
<img src="<?= $row['img'] ?>" title="<?= $row['sender'] ?>" alt="<?= $row['sender'] ?>">
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php <?php
# Секретный раздел # Секретный раздел
# Если я любой паладин, и смотрю не админа, или я сам админ. # Если я любой паладин, и смотрю не админа, или я сам админ.