如何将特定表的行中的值发布到其他php页面 [英] how to post values in a row of particular table to other php page
问题描述
我想更新特定学生的八个科目中的特定科目的分数。请检查以下代码。
echo ' 标记'。$ id。' 的详细信息'。$ semester。' semester'。' < br>';
$ query = ' SELECT子名,标记
FROM`2-1subjects`
加入`2-1`
ON`2-1subjects`.subcode =`2-1`.subcode
WHERE id ='。 '。$ id。 ' 跨度>;
$ sql = mysql_query($ query);
if(!$ sql)
{
die(' 无效查询:' 跨度> .mysql_error());
}
打印 < table border = 0 cellpadding = 10> ;
打印 < th> SUBJECT NAME< / th>;
打印 < th> MARKS< / th>;
while($ row = mysql_fetch_array($ sql))
{
Print < TR GT&;跨度>;
print < td>.$row [' subname']。 < / td>;
?>
< < span class =code-leadattribute> td > < 输入 type = text style = text-align:center value = <?php echo $ row [ 'marks']?> / > < / td >
< ? php
打印 < / tr>;
}
打印 < / table>;
?>
< 表格 方法 = POST action = 2-1marks_update.php >
< 输入 类型 = 提交 名称 = 提交 value = 更新标记 / > 跨度>';
< / form >
<? php
以下两个是我的2-1和2 -1分别表示主题表。这里''id''和''子代码''是主键。
id子代码标记
10kp1a1201 2-1sub#5 80
10kp1a1201 2-1sub#4 70
10kp1a1201 2-1sub#3 60
10kp1a1201 2-1sub#2 50
10kp1a1201 2-1sub#1 40
10kp1a1201 2-1sub#6 90
10kp1a1201 2-1sub#7 100
10kp1a1201 2-1sub#8 80
子代码子名称积分
2-1sub#1 s1 4
2 -1sub#2 s2 2
2-1sub#3 s3 2
2-1sub#4 s4 4
2-1sub#5 s5 2
2-1sub#6 s6 4
2-1sub#7 s7 2
2-1sub#8 s8 2
我的问题是因为我已检索到''表格中的子名称''和相应的''标记'',如上面的代码所示,在while循环中使用相同的文本框。现在我想根据上下文更新2或3个科目。然后如何将修改过的标记以及表格行中与其相对的主题名称传递到另一页面。
如何获得标记的主题名称和值检索到的表格行中的文本框,这样更新tesk取决于这个(子名称,标记)对。
请帮助我。任何答案都很明显。帮帮我。
id。' in'。
semester。' semester'。< span class =code-string>' < br>';
query = ' SELECT子名,标记
FROM`2-1subjects`
加入`2-1`
ON`2-1subjects`.subcode =`2-1`.subcode
WHERE id ='。 '跨度>
I want to update marks of a particular student in particular subject out of eight subjects. please inspect the following code.
echo 'Marks Details of '.$id.' in '.$semester.' semester'.'<br>';
$query='SELECT subname,marks
FROM `2-1subjects`
JOIN `2-1`
ON `2-1subjects`.subcode=`2-1`.subcode
WHERE id='."'".$id."'";
$sql=mysql_query($query);
if(!$sql)
{
die('invalid Query:'.mysql_error());
}
Print "<table border=0 cellpadding=10>";
Print "<th>SUBJECT NAME</th>";
Print "<th>MARKS</th>";
while($row = mysql_fetch_array($sql))
{
Print "<tr>";
print "<td>".$row['subname'] . "</td> ";
?>
<td> <input type="text" style="text-align:center" value="<?php echo $row['marks'] ?>" /></td>
<?php
Print "</tr>";
}
Print "</table>";
?>
<form method="POST" action="2-1marks_update.php" >
<input type="submit" name="submit" value="Update Marks"/>';
</form>
<?php
and the below two are my 2-1 and 2-1subjects tables respectively. here ''id'' and ''subcode'' are primary keys.
id subcode marks
10kp1a1201 2-1sub#5 80
10kp1a1201 2-1sub#4 70
10kp1a1201 2-1sub#3 60
10kp1a1201 2-1sub#2 50
10kp1a1201 2-1sub#1 40
10kp1a1201 2-1sub#6 90
10kp1a1201 2-1sub#7 100
10kp1a1201 2-1sub#8 80
subcode subname credits
2-1sub#1 s1 4
2-1sub#2 s2 2
2-1sub#3 s3 2
2-1sub#4 s4 4
2-1sub#5 s5 2
2-1sub#6 s6 4
2-1sub#7 s7 2
2-1sub#8 s8 2
my question is since i have retrieved ''subname'' and respective ''marks'' in a table as shown in the above code using the same textbox in a while loop. Now i want to update 2 or 3 subjects according to the context. then how the modified marks along with subject name opposite to it in a table row are passed to another page.
How can i get the subjectname and value of the marks in the textbox from the retrieved table row , such that the updation tesk is depends on this (subname, marks) pair.
please help me. any answer is appreciable. Help me.
id.' in '.
semester.' semester'.'<br>';
query='SELECT subname,marks FROM `2-1subjects` JOIN `2-1` ON `2-1subjects`.subcode=`2-1`.subcode WHERE id='."'".
这篇关于如何将特定表的行中的值发布到其他php页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!