04.01.2017, 13:24
I think it is correct, but why always do not have the data from the table bans? always considered empty tables
PHP код:
<section class="page-section parallax directions" id="location" style="padding-top:15%">
<div class="container div-table">
<div class="parallax-bg" data-stellar-background-ratio="0.5" data-stellar-vertical-offset="-150"></div>
<div class="parallax-overlay"></div>
<div class="parallax-inner text-center">
<table class="table table-bordered">
<thead>
<td>Username</td>
<td>IP</td>
<td>Banner</td>
<td>Reason</td>
<td>Banned From</td>
<td>Unbanned</td>
</thead>
<?php
$query = $koneksi->prepare("SELECT user_banned, bIP, ban_reason, ban_time, (ban_timestamp + (ban_time * 60) - strftime('%%s', 'now')) as banTimeLeft, strftime('%%d-%%m-%%Y %%H:%%M', datetime(ban_timestamp + (ban_time * 60), 'unixepoch')) as banExpired, strftime('%%d-%%m-%%Y %%H:%%M', datetime(ban_timestamp, 'unixepoch')) as bannedFrom, user_banner FROM `bans`");
$query->execute();
if($query->rowCount() == 0)
{
echo "<tr><td colspan='6'><small>There's no player on ban list</small></td></tr>";
}
while($data = $query->fetch())
{
if($data['ban_time'] == 0)
{
$data['banExpired'] = "Never";
}
echo "<tr><td>".$data['user_banned']."</td>";
echo "<td>".$data['bIP']."</td>";
echo "<td>".$data['user_banner']."</td>";
echo "<td>".$data['ban_reason']."</td>";
echo "<td>".$data['bannedFrom']."</td>";
echo "<td>".$data['banExpired']."</td></tr>";
}
?>
</table>
</div>
</div>
</section>
PHP код:
CREATE TABLE IF NOT EXISTS `bans` (
`BanID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_banned` varchar(50) NOT NULL,
`bIP` varchar(50) NOT NULL,
`user_banner` varchar(50) NOT NULL DEFAULT '*',
`ban_reason` varchar(50) NOT NULL DEFAULT '*',
`ban_timestamp` int(11) unsigned NOT NULL,
`ban_time` int(11) unsigned NOT NULL,
PRIMARY KEY (`BanID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=122 ;
--
-- Dumping data for table `bans`
--
INSERT INTO `bans` (`BanID`, `user_banned`, `bIP`, `user_banner`, `ban_reason`, `ban_timestamp`, `ban_time`) VALUES
(1, 'Naswara', '140.0.44.94', 'Server Ban', 'Vehicle Spawning', 1481960211, 0),
(2, 'AK59', '119.30.39.51', 'Prodigy', 'aimbot', 1481966183, 0),
(3, 'AK59', '119.30.39.51', 'TheOneShooT', 'aimbot (ip ban)', 1481966225, 0),