Hey, everyone. It's me again.
So I'm doing abit of OOP here, and I have a bit of problem, where PDO returns only 1 row instead all rows, my code for example is below. This happens for every function, it only returns one row.
I don't really know what I'm doing - i wish i did. anyway, I hope y'all can help me.
Thanks.
So I'm doing abit of OOP here, and I have a bit of problem, where PDO returns only 1 row instead all rows, my code for example is below. This happens for every function, it only returns one row.
PHP:
public static function getBans()
{
global $conn;
$stmt = $conn->prepare("SELECT * FROM bans");
$stmt->execute();
$stmt = $stmt->fetchAll();
foreach($stmt as $ban)
{
return "<tr>
<th scope='row'>".$ban['id']."</th>
<td>".self::userDataFromId($ban['user_id'],'username')."</td>
<td>".$ban['ip']."</td>
<td>".$ban['machine_id']."</td>
<td>".self::userDataFromId($ban['user_staff_id'],'username')."</td>
<td>".date('Y-m-d H:s:i',$ban['timestamp'])."</td>
<td>".date('Y-m-d H:s:i',$ban['ban_expire'])."</td>
<td>".$ban['ban_reason']."</td>
<td>".$ban['type']."</td>
<td><a href='editban?id=".$ban['id']."'><i class='fa fa-pencil'></i></a> <a id='delete' href='#' data-id='".$ban['id']."'><i class='fa fa-trash'></i></td>
</tr>";
}
}
public static function getFilters()
{
global $conn;
$stmt = $conn->prepare("SELECT * FROM `hk`.`wordfilter` LIMIT 0, 1000");
$stmt->execute();
$stmt = $stmt->fetchAll();
foreach($stmt as $filter)
{
return "<tr id='". $filter['id']. "'>
<td>".$filter['key']."</td>
<td>".$filter['replacement']."</td>
<td><a href='editfilter?key=".$filter['key']."' id='edit' ><i class='fa fa-pencil'></i></a></td>
";
}
}
Thanks.