<?php
require 'connect.php';
$search = $_POST["search"];
这两个查询工作正常。所以我使用了下面的格式。
$result = mysql_query("SELECT * FROM `subjects` WHERE $search = `student_id`");
$result2 = mysql_query("SELECT * FROM `grades` WHERE $search = `student_id`");
while($row = mysql_fetch_array($result)) {
$row2 = mysql_fetch_array($result2);
echo"<table border='1'>";
echo "<tr>";
echo "<th>Subjects:</th>";
echo "<th>Current Mark:</th>";
echo "<th>Edit Mark:</th>";
echo"</tr>";
echo"<tr>";
echo "<td>". $row['c1'] ."</td>";
echo "<td>". $row2['m1'] ."</td>";
echo "<td><input type='text' name='m1'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>". $row['c2'] ."</td>";
echo "<td>". $row2['m2'] ."</td>";
echo "<td><input type='text' name='m2'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>". $row['c3'] ."</td>";
echo "<td>". $row2['m3'] ."</td>";
echo "<td><input type='text' name='m3'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>". $row['c4'] ."</td>";
echo "<td>". $row2['m4'] ."</td>";
echo "<td><input type='text' name='m4'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>". $row['c5'] ."</td>";
echo "<td>". $row2['m5'] ."</td>";
echo "<td><input type='text' name='m5'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>". $row['c6'] ."</td>";
echo "<td>". $row2['m6'] ."</td>";
echo "<td><input type='text' name='m6'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>". $row['c7'] ."</td>";
echo "<td>". $row2['m7'] ."</td>";
echo "<td><input type='text' name='m7'></td>";
echo "</tr>";
echo "</table>";
echo "<input type='submit' name='submit' value='Submit'>";
echo "</form>";
}
$M1 = $_POST["m1"];
$M2 = $_POST["m2"];
$M3 = $_POST["m3"];
$M4 = $_POST["m4"];
$M5 = $_POST["m5"];
$M6 = $_POST["m6"];
$M7 = $_POST["m7"];
如果我输入数字e.x,它会起作用。 11111
否则只会在表格中输入空格。
我试过'“。$ search。”'
我试过“。$ search。”
mysql_query("UPDATE grades SET m1 = '$M1', m2 = '$M2',m3 = '$M3',m4 = '$M4',m5 = '$M5',m6 = '$M6',m7 = '$M7' WHERE $search = `student_id`");
?>
表
+ ------------ + --- + + --- --- --- + + --- + + --- --- +
| student_id数据| M1 | M2 |立方米| M4 | M5 | M6 | M7 |
+ ------------ + --- + + --- --- --- + + --- + + --- --- +
===数据库d1
==表格等级的表格结构
| ------ |栏|类型|空|缺省 | ------ | // student_id数据 // | INT(5)|没有| | M1 |文|没有| | 2 |文|没有| | M3 |文|没有| | M4 |文|没有| | M5 |文|没有| | M6 |文|没有| | M7 |文|没有| ==转储表等级的数据
| 11111 | | | | | | | | 11112 | FG | FD | F | F | FD | F | F
===数据库d1
==表格主题的表格结构
| ------ |栏|类型|空|缺省 | ------ | // student_id数据 // | INT(11)|没有| | C1 |文|没有| | C2 |文|没有| | C3 |文|没有| | 4 |文|没有| | C5 |文|没有| | 6 |文|没有| | 7 |文|没有| ==转储表主题的数据
| 11111 |英语|数学|科技|体育| IT |艺术|历史 | 11112 | grdgg | vsbvbbb | bdbbrfd | bdbrb | dbrbfbf | fbdfbdbf | dbfbdfb
答案 0 :(得分:1)
编辑:值不会反映到输入中,而是反映在 td 中。将行值插入input元素,以便$ _POST值。
$value = $row['m1'];
echo "<td><input type='text' name='m1' value='$value'></td>";
答案 1 :(得分:0)
你应该修复
$result = mysql_query("SELECT * FROM `subjects` WHERE student_id='$search'");
$result2 = mysql_query("SELECT * FROM `grades` WHERE student_id='$search'");