调用到HTML文件的PHP表单不';如果有其他形式,则不起作用

调用到HTML文件的PHP表单不';如果有其他形式,则不起作用,php,html,forms,Php,Html,Forms,我用include命令调用一个PHP文件中的多个表单。如果我将include命令放在HTML页面中其他表单之前,那么它就可以工作了。问题是我需要调用其他表单下面的“include”命令。我提出的解决方案是在页面开始处调用PHP文件并隐藏div。然后我在页面底部再次调用该文件,解决了这个问题。还有别的解决办法吗?为什么要这样做 非工作示例: <form></form> <form></form> include 'phpfil

我用include命令调用一个PHP文件中的多个表单。如果我将include命令放在HTML页面中其他表单之前,那么它就可以工作了。问题是我需要调用其他表单下面的“include”命令。我提出的解决方案是在页面开始处调用PHP文件并隐藏div。然后我在页面底部再次调用该文件,解决了这个问题。还有别的解决办法吗?为什么要这样做

非工作示例:

    <form></form>
    <form></form>
    include 'phpfilewithotherforms.php';
    <div style="display:none;">include 'phpfilewithotherforms,php';</div>
    <form></form>
    <form></form>
    include 'phpfilewithotherforms.php';

包括“phpfilewithotherforms.php”;
工作示例,但不可行:

    include 'phpfilewithotherforms.php';
    <form></form>
    <form></form>
包括“phpfilewithotherforms.php”;
工作示例:

    <form></form>
    <form></form>
    include 'phpfilewithotherforms.php';
    <div style="display:none;">include 'phpfilewithotherforms,php';</div>
    <form></form>
    <form></form>
    include 'phpfilewithotherforms.php';
包括“phpfilewithotherforms,php”;
包括“phpfilewithotherforms.php”;
我正在调用的PHP文件示例:

    while($row = mysql_fetch_array($result))
    {
    echo "<div style='padding:20px;margin:15px;background:offwhite;border-style:solid;border-width:1px;border-color:lightgray;'>" .
    "<form method='post' name='example'>" .
    "<span class='detail'><b>Title:</b>  " .  
    $row['mytitle'] .
    "      " .
    "<input type='hidden' value='" . stripslashes($row['mytitle']) . "' . name='title'>" .
    "<span style='float:right'>" .
    "<input type='submit' value='Edit' name='edit'>" .
    "<input type='submit' value='Preview' name='preview'>" .
    "</span>" .
    "</form>" .
    }
while($row=mysql\u fetch\u array($result))
{
“回声”。
"" .
“标题:”。
$row['mytitle']。
"      " .
"" .
"" .
"" .
"" .
"" .
"" .
}

你必须按顺序工作。我会将包含的文件分成两部分,一部分是表单之前需要的代码,另一部分是表单之后需要的代码

我通常使用



您是否遗漏了这些内容?

可能使用输出缓冲来防止在生成完整的html页面之前将数据发送到浏览器。我遇到了一个类似的问题,正如Danny所说,使用ob_start和ob_flush强制按顺序发送到浏览器。这是我唯一的解决办法,但我从未发现为什么它不起作用,因为我严格地对s进行了排序。谢谢你们。使用php缓冲区就成功了。我这样做是最好的解决方案,还是只是使用了一种变通方法?看看你的代码。首先,我会检查你的错误日志,看是否有任何语法错误。在PHP中,不需要连接行。另外,看看你的HTML,有一些额外的“.”。