Files
Globaly-CSS-Practice/search_people.php
2024-06-24 07:52:54 +02:00

129 lines
3.3 KiB
PHP
Executable File

<?php
require 'php/connect.inc.php';
if (isset($_GET['search_text'])) {
$search_text = $_GET['search_text'];
echo '<h2>Search Results for: ' . htmlspecialchars($search_text) . '</h2>';
$con = mysqli_connect($mysql_host, $mysql_user, $mysql_pass);
if (mysqli_select_db($con, $mysql_db)) {
$query = "SELECT `name`, `surname`, `email`, `birth_day`, `birth_month`, `birth_year` FROM `globaly_accounts` WHERE `name` LIKE '" . mysqli_real_escape_string($con, $search_text) . "%'";
$query_run = mysqli_query($con, $query);
if (mysqli_num_rows($query_run) > 0) {
echo '<table border="1">
<tr>
<th>Name</th>
<th>Surname</th>
<th>Email</th>
<th>Birth Date</th>
</tr>';
while ($query_row = mysqli_fetch_assoc($query_run)) {
$name = $query_row['name'];
$surname = $query_row['surname'];
$email = $query_row['email'];
$birth_date = $query_row['birth_day'] . '.' . $query_row['birth_month'] . '.' . $query_row['birth_year'] . '.';
echo '<tr>
<td>' . htmlspecialchars($name) . '</td>
<td>' . htmlspecialchars($surname) . '</td>
<td>' . htmlspecialchars($email) . '</td>
<td>' . htmlspecialchars($birth_date) . '</td>
</tr>';
}
echo '</table>';
} else {
echo 'No results found.';
}
} else {
echo 'Database selection failed.';
}
mysqli_close($con);
} else {
echo 'No search text provided.';
}
?>
<style>
body{
display: flex;
flex-direction: column;
align-items: center;
justify-content: start;
background-image: url('assets/images/image10.jpg');
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
h2{
color: #15c1cb;
font-size: 20px;
}
table {
font-size: 10px;
width: fit-content;
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
background-color: #f2f2f2;
}
th, td {
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
color: #15c1cb;
}
#btn-back{
margin-top:30px;
}
@media screen and (min-width:768px) {
body{
justify-content: center;
}
table{
font-size: 20px;
}
h2{
font-size: 50px;
}
}
@media screen and (min-width:992px) {
body{
justify-content: center;
}
table{
font-size: 30px;
}
h2{
font-size: 50px;
}
}
</style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search people</title>
<link rel="stylesheet" href="style/style.css">
</head>
<body>
<div id="btn-back">
<a href="people.php"><input class="view-more" type="submit" value="Back"></a>
</div>
</body>
</html>