0
<iframe id="frame1" name="frame1" align="center" src="committee_assign1.php" height="400" width="700">
                </iframe>


                    <center><input onClick="submitiframeform(); return false;" type="button" name="submit" value="Submit" />
                <script type="text/javascript">

function submitiframeform(){
    window.frames['frame1'].document.forms['fypassign'].submit();
}
</script>

以上是主页名称committee_assign.php ..

下面是 iframe 调用委员会_assign1.php 的页面。

<?php
    include '../database.php';
    include 'valid_login.php';
       if(isset($_POST['submit'])) { 

    $continue = FALSE;
    $i = 0; 
    while ($continue == FALSE) { 
        if (isset($_POST['id_'.$i])) { 
            $fypcomm = $_POST['fypcomm_'.$i];
            $user = $_POST['id_'.$i];
            $sql = mysql_query(" UPDATE Lecturer SET LectFypCommittee = '$fypcomm' WHERE LectID = '$user' ") 
                or die(mysql_error());
            mysql_query($sql);
        } else
            {$continue = TRUE;}
        $i++;
    }

     echo ("<SCRIPT LANGUAGE='JavaScript'>

        window.location.href='../committee/committee_assign1.php'
        </SCRIPT>");

}

    ?>
<head>


</head>

<body>
<form id="fypassign" name="fypassign" method="post" action="" target="_self" onSubmit="">

                <?php


                $counter = 0;

                echo "<table class ='box'>";
                    echo "<thead>";
                    echo "<tr>";
                    echo "<th align='left' valign='top'>"."Lecturer Name"."</th>";
                    echo "<th align='left' valign='top'>"."FYP Committee"."</th>";    
                    echo "</tr>";

                    $sql = mysql_query(" SELECT * FROM Lecturer ORDER BY LectFypCommittee DESC, LectName ASC ") or die(mysql_error());
                    while($info = mysql_fetch_assoc($sql)) {
                        $idcount = "id_".$counter;
                        echo "<input type='hidden' name='$idcount' id='$idcount' value={$info['LectID']}  />";

                        echo "<tr>";

                        echo "<td>";
                            echo $info['LectName'];
                        echo "</td>";

                        echo "<td>";
                            $formname = "fypcomm_".$counter;
                            echo "<select name='$formname'>";
                            //to convert the flag value to user understandable language
                            if ($info['LectFypCommittee'] == '0'){
                                $dbfyp = 'No';
                            }
                            else $dbfyp = 'Yes';

                            echo "<option selected='selected' value='{$info['LectFypCommittee']}'>".$dbfyp."</option>";
                            if ($info['LectFypCommittee'] == '0'){
                                echo "<option value='1'>".'Yes'."</option>";
                            }
                            else echo "<option value='0'>".'No'."</option>";
                            echo "</select>";
                        echo "</td>";

                        echo"</tr>";
                        $counter++;
                    }

                    echo "</table>";
                ?>

                </form>

                </body>

我单击父页面上的提交按钮,页面刷新,但值未更新。

有人可以在这里指导我吗?

很抱歉发布这么长的代码,我希望你们能更多地理解我在做什么。TQ

4

2 回答 2

0

您的commitment_assign.php 中没有input名为提交:

if(isset($_POST['submit']))

您必须检查以下内容:

if(isset($_POST))

于 2013-03-03T09:02:29.573 回答
0

您正在检查提交是否已发布,但您没有名为提交的输入。添加一个名为 submit 并带有一些值的输入,并检查该帖子提交是否存在。如果您不想看到额外的输入,可以将其隐藏。

if($_POST['submit']) 正在检查 post 数组中是否存在键为 'submit' 的值。$_POST 数组中的所有键和值分别是表单元素的名称和值。

于 2013-03-03T09:04:32.267 回答