我想将值更新为更正或更新形式的学生更改值。
直到知道我能够使用ajax和json从数据库的下拉列表中选择的名称的基础上获取和显示文本框中的值。但是当我尝试更新数据库时它不起作用......
HTML:
<select name="u_stu" id="u_stu" onchange="show(this.value);" style="float:right; height:30px; width:180px;">
<option selected="selected" disabled="disabled">Choose</option>
<option>stu1</option>
<option>stu2</option>
<option>stu3</option>
</select>
name: <input type="text" id="name" name="name" style="float:right; height:20px; width:200px;"/><br /><br />
age: <input type="text" id="age" name="age" style="float:right; height:20px; width:200px;" /><br /><br />
phone: <input type="text" id="phone" name="u_ver_txt" style="float:right; height:20px; width:200px;" /><br /><br />
address: <input type="text" id="add" name="add" style="float:right; height:20px; width:200px;" /><br /><br />
hobby: <input type="text" id="hobby" name="hobby" style="float:right; height:20px; width:200px;" /><br /><br />
<input type="submit" value="Submit" name="u_s2" id="u_s2" style="position:relative; top:-180px; "/>
MYSQL PHP
<?php
$c=mysql_connect("localhost","abc","xyz");
mysql_select_db("root");
if(isset($_POST['u_s2']))
{
$name=$_POST["name"];
$age=$_POST["age"];
$phone=$_POST["phone"];
$address=$_POST["address"];
$hobby=$_POST["hoddy"];
$id=$_POST["u_id"];
$q2="UPDATE student SET
name=$name,age=$age,phone=$phone,address=$address,hobby=$hobby WHERE Sr. no=$id";
mysql_query($q2);
}
?>