我正在为我的学校做一名考勤人员。我正在将建议提交给我的上一篇multi question我获得了代码建议,例如
INSERT INTO attendence (FName, LName, Mark)
SELECT 'FName1', 'LName1', 1
UNION ALL
SELECT 'FName2', 'LName2', 2
UNION ALL
SELECT 'FName3', 'LName3', 3
或
INSERT INTO attendence (FName, LName, Mark)
$FName, $LName, $Mark
但是,这些建议限制了我只允许插入尽可能多的行。因为我的表单调用了表中学生的名字,所以每天可能会添加越来越多的名称。我不想继续在我的select语句中添加更多行。什么sql语句允许我输入很多行。
<?php
if(isset($_POST['search']))
{
$valueToSearch = $_POST['valueToSearch'];
// search in all table columns
// using concat mysql function
$query = "SELECT * FROM `records` WHERE CONCAT(`FName`, `LName`) LIKE '%".$valueToSearch."%'";
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM `records`";
$search_result = filterTable($query);
}
// function to connect and execute the query
function filterTable($query)
{
$connect = mysqli_connect("host", "user", "password", "database");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>
<form action="submit.php"method="post">
<table border="1" align="center">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Mark</th>
</tr>
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td>
<input type="text" name="FName" value="<?php echo $row['FName']?>"/>
</td>
<td>
<input type="text" name="LName" value="<?php echo $row['LName']?>"/>
</td>
<td>
<select name="Mark" id="Mark">
<option value="Present">Present</option>
<option value="Tardy">Tardy</option>
<option value="Absent">Absent</option>
</select>
</td>
<table align="center">
<tr>
<td>
<input type="submit" value="Submit" >
</td>
</tr>
</table>
</table>
</table>
</form>