通过php表单更新数据库

时间:2014-04-30 16:34:36

标签: php sql

代码正常执行但是当用户选择更新时,代码不会执行它应该做的事情,即使用查询更新数据库。我已经测试了查询,它运行正常。

我看了其他问题讨论同样的事情,但我没有在这些问题中找到解决问题的方法。

<?php
    $s_course = $_POST['course_id'];
    ...
    $conn=oci_connect("****" , "****" , "****");
    $sql=oci_parse($conn, "select * from evaluate where Course_ID ='$s_course'and Section = '$s_section' and Exam_Type = '$s_exam_type' and Exam_ID = '$s_exam_num' and Roll_Number = '$s_roll_no'");
    oci_execute($sql);
    $row=oci_fetch_array($sql);
    echo "<table align='center'>";
    echo "<tr class='header'><td>Roll No.</td><td>Marks Scored</td><td>Attendence</td><td>New Marks</td></tr>";
    echo "<tr><td>$row[0]</td><td>$row[4]</td><td>$row[5]</td><td>";
?>
    <form method="post" action="update_student_marks.php">
        <input type="number" name="newmarks"></input>
    </form>
<?php
    echo  "</td></tr>";
    echo "</table>";
?>
    <form method="post" action="update_student_marks.php">
        <input type="submit" name="update" value="Update"></input>
    </form>
<?php

    if(isset($_POST["update"]))        // not coming in even if 'Update' key is pressed
    {
        $sql=oci_parse($conn, "update evaluate set Marks = '$_update_marks' where Course_ID ='$s_course' and Section = '$s_section' and Exam_Type = '$s_exam_type' and Exam_ID = '$s_exam_num' and Roll_number = '$s_roll_no'");
        oci_execute($sql);

        $sql=oci_parse($conn, "commit");
        oci_execute($sql);
    }
?>

感谢您的帮助。

0 个答案:

没有答案