У меня есть таблица, в которой у каждой строки есть имя и раскрывающийся список с именами всех возможных заданий в моей базе данных. Я хочу, чтобы пользователь мог назначать задания на любое количество имен. Тогда будет кнопка отправки, которая обновит базу данных только теми, у кого выбрано задание. Я не уверен, как обновить только измененные строки, я могу сделать это формой? Спасибо за вашу помощь!
HTML:
<?php
session_start();
if(!isset($_SESSION['login'])) {
header('Location: AdminLogin.php');
exit;
}
$user = 'root';
$password = 'root';
$db = 'Senior Internships';
$host = 'localhost';
$conn = new mysqli($host, $user, $password, $db);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Internships</title>
<link href="css/Navbar.css" rel="stylesheet">
<link href="css/dropdown.css" rel="stylesheet">
<link href="css/Tables.css" rel="stylesheet">
</head>
<body>
<img src="BT-Square-Logo.png" class="logo" alt='BT Logo'>
<script src="js/dropdown.js"></script>
<header>
<div class="container">
<nav>
<ul>
<li><a href='Pre-approved_Internships.php'>Pre-approved Internships</a></li>
<li><a href='Logout.php'>Logout</a></li>
</ul>
</nav>
</div>
</header>
<h2>Students Not Yet Assigned</h2>
<div id="table-wrapper2">
<div id="table-scroll">
<div id="table-wrapper">
<table style="width:100%">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>1st Area of Interest</th>
<th>2nd Area of Interest</th>
<th>3rd Area of Interest</th>
<th>Internship</th>
</tr>
<?php
$result = mysqli_query($conn, "SELECT FName, LName, AreaofInterest1, AreaofInterest2, AreaofInterest3 FROM Seniors WHERE Visibility=0");
while($row = mysqli_fetch_array($result)):
?>
<tr>
<td><?= $row['FName']; ?></td>
<td><?= $row['LName']; ?></td>
<td><?= $row['AreaofInterest1']; ?></td>
<td><?= $row['AreaofInterest2']; ?></td>
<td><?= $row['AreaofInterest3']; ?></td>
<td>
<select>
<?php
$result2 = mysqli_query($conn, "SELECT Company FROM Internships");
while($row2 = mysqli_fetch_array($result2)): ?>
<option vaue="<?= $row2['Company']; ?>"><?= $row2['Company']; ?></option>
<?php endwhile ?>
</select>
</td>
</tr>
<?php endwhile; ?>
</table>
</div>
</div>
</div>
</body>
<footer><p>© Eliav Hamburger 2018 Admins login <a href='AdminLogin.php'>here</a></p></footer>
</html>
Форматирование таблицы CSS (включен только CSS таблицы):
td, th {
padding: 10px;
}
table {
border-collapse: collapse;
border: none;
}
th {
color: white;
background-color: #302e7f;
}
th a {
color: white;
text-decoration: none;
}
tr:nth-child(2n+1) {
background-color: #91A6BB;
}
#table-wrapper {
position:relative;
border-style: solid;
border-radius: 7px;
border-color: #91A6BB;
}
#table-scroll {
height:250px;
overflow:auto;
}
#table-wrapper2 table {
width:100%;
}
#table-wrapper2 table thead th .text {
position:absolute;
top:-20px;
z-index:2;
height:20px;
width:35%;
border:1px solid red;
}