简体   繁体   English

PHP更新Mysql数据库中的值

[英]PHP Updating values in Mysql database

I have a PHP page where it shows a students details from the database (Mysql) which the student fills in during the registration process. 我有一个PHP页面,其中显示学生在注册过程中填写的数据库(Mysql)中的学生详细信息。

After logging in I display all the entries made, in a table and give a option to edit the information. 登录后,我在表格中显示所有输入的内容,并提供编辑信息的选项。

I am finding it difficult to update the information which is edited to the database , as I want the student to remain on the same page. 我发现很难更新已编辑到数据库中的信息,因为我希望学生留在同一页面上。

    <?php
ini_set('error_reporting', E_ALL ^ E_NOTICE ^ E_WARNING);
$id = $_GET['id'];
$connection = mysql_connect('localhost', 'root', '1234') or die('Could not connect');
mysql_select_db('PMS', $connection) or die('Database not found.');
$query = "select * from student_database WHERE student_id=".$id."";
$result = mysql_query($query) or die('Query wrong');
echo "<br /><br /><br /><br /><center>";
$i = 0;
$row = mysql_fetch_array($result);
?>
<table width="500" border="1" bordercolor="black" cellpadding="5" cellspacing="5">
    <?php
    while ($i < mysql_num_fields($result)) {
        $meta = mysql_fetch_field($result, $i);
        if ($meta->name != "email" && $meta->name != "password") {
            echo "<tr><td>".$meta->name."</td>";
            echo "<td><input type=text name=\"".$meta->name."\" disabled=true value=\"".$row[$i]."\" /></td></tr>";
        }

        $i = $i + 1;
    }
    ?>
</table>
<br/>
<input type="button" id="editbutton"  value="Edit" onclick="editfields()">

There is a update button which appears as soon as the edit button is pressed and all the fields become editable (they were set as disabled on page load). 按下编辑按钮,所有字段均变为可编辑状态(将其设置为页面加载时已禁用)后,将立即显示一个更新按钮。

Now my questions is: 现在我的问题是:

How do I update the newly fed information into the database without leaving the page? 如何在不离开页面的情况下将新提供的信息更新到数据库中?

请在其他页面上进行更新如果您填写的更好,请使用标题和成功更新信息数据的页面在此页面上重定向

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM