31TSAI/ProjektowanieBazDanych/projekt1_v1.1.php

74 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2023-09-11 13:56:00 +02:00
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description"
content="Wylazowski Klasa 5D2">
<title>Strona Główna</title>
<style>
td {
padding: 5px;
}
</style>
</head>
<body>
<h2 align="center">Baza danych Wylazowski, Klasa 5D2</h2>
2023-09-18 13:00:06 +02:00
<h3 align="center">Tabela emp</h3>
2023-09-11 13:56:00 +02:00
<table cellspacing="0" cellpadding="0" border="1" style="width: 90%;" align="center">
<tr bgcolor="#A000FF">
<td>ID</td>
<td>NAZWISKO</td>
<td>IMIĘ</td>
<td>USER ID</td>
<td>UWAGI</td>
<td>DATA REJESTRACJI</td>
</tr>
<?php
2023-09-18 13:00:06 +02:00
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'baza_testowa';
ini_set('display_errors', '0');
$conn = mysqli_connect($host,$username,$password,$database);
$conn_err = mysqli_connect_errno();
if ($conn_err) {
switch ($conn_err){
case 1049:
$kom = "Nieprawidłowa nazwa bazy danych (".$database.")";
break;
}
}
2023-09-11 13:56:00 +02:00
$query = "SELECT emp.id,
emp.first_name,
2023-09-11 14:43:35 +02:00
emp.last_name,
emp.comments,
emp.userid,
emp.start_date
2023-09-11 13:56:00 +02:00
FROM emp
WHERE emp.last_name LIKE 'n%';";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_array($result))
{
echo '<tr><td>';
printf("%d", $row['id']);
echo '</td><td>';
printf("%s", $row['last_name']);
echo '</td><td>';
printf("%s", $row['first_name']);
2023-09-11 14:43:35 +02:00
echo '</td><td>';
printf("%s", $row['userid']);
echo '</td><td>';
printf("%s", $row['comments']);
echo '</td><td>';
printf("%s", $row['start_date']);
2023-09-11 13:56:00 +02:00
echo '</td></tr>';
}
?>
</table>
</body>
</html>