我有一页分为几个部分。我喜欢在每个部分加载一个页面。如果我有一个表单并单击提交按钮或链接,我想在本节中显示结果。
例如:我在显示 php 页面的“item1_section2”部分manage_team_teacher.php
。在页面 manage_team_teacher.php 我有一个表单,如果我提交表单或单击链接,我想在“item1_section2”部分再次显示结果。我对如何执行此操作感到非常困惑,因为所有内容都在同一页面中(index.php
)。我是 PHP 新手,需要您的帮助。你有什么建议?
如您所见,我尝试了很多方法,但遇到了问题:我尝试从 URL 获取页面名称(在类别中)。
<a href="index.php?category=manage_team_teacher2.php&id_team=<?= $row['id_team']; ?>#item1_section2">manage</a></td>
以上是我尝试创建的链接示例
<div class="content" style="font-size:30px;">
<div class="section black" id="item1_section1" style="float: left; overflow: scroll; padding: 30px 0 0 30px; width: 869px;">
<h2>Section 1</h2>
<p>
sdffffffffffffffffffffffffff
sdffffff
sdf
</p>
<ul class="nav">
<li>1</li>
<li><a href="#item1_section2">2</a></li>
<li><a href="#item1_section3">3</a></li>
</ul>
</div>
<div class="section white" id="item1_section2" style="float: left; overflow: scroll; padding: 30px 0 0 30px; height:690px; width: 869px;">
<h2>Section 2</h2>
<p>
<?php
include "includes/tests/multiple_choice.php";
?>
</p>
<ul class="nav">
<li><a href="#item1_section1">1</a></li>
<li>2</li>
<li><a href="#item1_section3">3</a></li>
</ul>
</div>
<div class="section black" id="item1_section3">
<h2>Section 3</h2>
<p>
‘He scents thy footsteps in the snow
Wheresoever thou dost go,
Thro’ the wintry hail and rain.
When wilt thou return again?
</p>
<ul class="nav">
<li><a href="#item1_section1">1</a></li>
<li><a href="#item1_section2">2</a></li>
<li>3</li>
</ul>
</div>
</div>
</div>
<!--########################--ITEM 2--########################-->
<?php if ($row['settings_key'] == background-color){
echo '<div id="item2" class="item" style="background-color: #'.$row['settings_value'].';">';
}?>
<a name="item2"></a>
<div class="content" style="font-size:30px;">
<div class="section black" id="item2_section4" style="float: left; overflow: scroll; font-size: 18px; padding: 30px 0 0 30px; height:690px; width: 869px;">
<ul class="nav" style="float: left;">
<li>1</li>
<li><a href="#item2_section5">2</a></li>
<li><a href="#item2_section6">3</a></li>
</ul>
<h2>Section 1</h2>
<p>
<?php
include "create_new_team_teacher.php";
?>
</p>
</div>
<div class="section white" id="item2_section5" style="float: left; overflow: scroll; font-size: 18px; padding: 30px 0 0 30px; height:690px; width: 869px;">
<h2>Section 2</h2>
<p>
<?php
if(isset($_GET['category'])){
// include page about me
include($_GET['category']);
//else if is defined URL variable 'interests'
} else {
include('manage_team_teacher.php');
}
?>
</p>
<ul class="nav">
<li><a href="#item2_section4">1</a></li>
<li>2</li>
<li><a href="#item2_section6">3</a></li>
</ul>
</div>
<div class="section black" id="item2_section6">
<h2>Section 3</h2>
<p>
‘He scents thy footsteps in the snow
Wheresoever thou dost go,
Thro’ the wintry hail and rain.
When wilt thou return again?
</p>
<ul class="nav">
<li><a href="#item2_section4">1</a></li>
<li><a href="#item2_section5">2</a></li>
<li>3</li>
</ul>
</div>
</div>
</div>