<?php
class DataBase
{
private $user = 'root';
private $pass = '';
private $dsn = "mysql:host=localhost;dbname=students_bd";
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
);
private function makeConnect()
{
$pdo = new PDO($this->dsn, $this->user, $this->pass, $this->opt);
return $pdo;
}
public function getData()
{
$pdo = $this->makeConnect();
$sql = 'SELECT * FROM students ORDER BY name';
echo "<table border=1 bordercolor=black>";
echo "<tr><td>Имя</td><td>Фамилия</td><td>Пол</td><td>Группа</td>
<td>Email</td><td>Средний Бал</td><td>Местный/Приезжий</td><td>Год Рождения</td>
</tr>";
foreach ($pdo->query($sql) as $students) {
echo "<tr><td>".$students['Name']." </td><td>".$students['Surname']." </td>
<td>".$students['Sex']." </td><td>".$students['GroupNumber']." </td>
<td>".$students['Email']." </td><td>".$students['Mark']." </td>
<td>".$students['Local']." </td><td>".$students['Birth Date']." </td></tr>";
}
echo "</table>";
}
}
$page = new DataBase;
$page->getData();
PD9waHAKY2xhc3MgRGF0YUJhc2UKewogICAgcHJpdmF0ZSAkdXNlciA9ICdyb290JzsKICAgIHByaXZhdGUgJHBhc3MgPSAnJzsKICAgIHByaXZhdGUgJGRzbiA9ICJteXNxbDpob3N0PWxvY2FsaG9zdDtkYm5hbWU9c3R1ZGVudHNfYmQiOwogICAgcHJpdmF0ZSAkb3B0ID0gYXJyYXkoCiAgICAgICAgUERPOjpBVFRSX0VSUk1PREUgPT4gUERPOjpFUlJNT0RFX0VYQ0VQVElPTiwKICAgICAgICBQRE86OkFUVFJfREVGQVVMVF9GRVRDSF9NT0RFID0+IFBETzo6RkVUQ0hfQVNTT0MKICAgICk7CgogICAgcHJpdmF0ZSBmdW5jdGlvbiBtYWtlQ29ubmVjdCgpCiAgICB7CiAgICAgICAgJHBkbyA9IG5ldyBQRE8oJHRoaXMtPmRzbiwgJHRoaXMtPnVzZXIsICR0aGlzLT5wYXNzLCAkdGhpcy0+b3B0K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