我想提交一份 html
表值到 mysql
table。前两列 html
表是从 mysql
表 'student'
第三栏在网上填写。我想将所有三列插入到中的另一个表中 msyql
. 我只是在插入所有表值时遇到了问题。代码如下under:-
<html>
<body>
<?php
$connection = mysqli_connect ('localhost', 'user', 'password', 'db');
if (!$connection){
echo 'Not connected to server';
}
$select_db = mysqli_select_db($connection, 'db');
if (!$select_db){
echo 'Not connected to database';
}
$SelectClass = $_POST ['selectclass'];
$sql= "SELECT * FROM students WHERE class = '$SelectClass'";
$query = mysqli_query($connection, $sql);
if (!$query) {
die ('SQL Error: ' . mysqli_error($connection));
}
mysqli_close($connection);
?>
<body>
<div class="container">
<h1><strong>Please enter marks of each student for subject</strong></h1>
<table id = "result" class="data-table">
<caption class="title"></caption>
<thead>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Marks Obtained</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
$total = 0;
while ($row = mysqli_fetch_array($query))
{
$stu = $row['stu_id'] == 0 ? '' : number_format($row['stu_id']);
echo '<tr>
<td>'.$row['student_id'].'</td>
<td>'.$row['student_name'].'</td>
<td>'."<div class='search-block clearfix'><input name='obtmarks' placeholder='' type='number'></div>".'</td>
</tr>';
$total += $row['stu_id'];
$no++;
}?>
</tbody>
</table>
<button type="submit" class="btn btn-warning" value="insert" align="right">Update<span class="glyphicon glyphicon-send"></span></button>
</form>
</div>
</body>
</html>
1条答案
按热度按时间2mbi3lxu1#
请看下面的更新代码: