I have multiple forms in a PHP file that I call with the 'include' command. If I put the include command before the other forms in the HTML page then it works. The problem is that I need to call the 'include' command below the other forms. The solution I came up with was to call the PHP file at the beginning of the page and hide the div. I then called the file again at the bottom of the page which fixed the problem. Is there another solution? Why is it doing this?
Non working example:
<form></form>
<form></form>
include 'phpfilewithotherforms.php';
working example but not viable:
include 'phpfilewithotherforms.php';
<form></form>
<form></form>
working example:
<div style="display:none;">include 'phpfilewithotherforms,php';</div>
<form></form>
<form></form>
include 'phpfilewithotherforms.php';
Sample of PHP file that I'm calling:
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>" .
}