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>

上記は、メインページの名前である community_assign.php ..

以下は、iframe が Committee_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

inputsubmit という名前の community_assign.php にはありません。

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

次のようなもので確認する必要があります。

if(isset($_POST))

于 2013-03-03T09:02:29.573 に答える
0

送信が投稿されたかどうかを確認していますが、送信という名前の入力がありません。submit という名前の入力に何らかの値を追加し、その post submit が存在するかどうかを確認します。余分な入力を見たくない場合は、非表示にすることができます。

if($_POST['submit']) は、投稿配列にキー 'submit' を持つ値があるかどうかを確認しています。$_POST 配列のすべてのキーと値は、それぞれフォーム要素の名前と値です。

于 2013-03-03T09:04:32.267 に答える