页面的多个部分。为每个部分加载不同的页面

时间:2012-12-26 13:16:35

标签: php html css

我有一个页面分为几个部分。在每个部分我都想加载一个页面。如果我有一个表单,我单击提交按钮或链接,我想在此部分显示结果。

例如:我在“item1_section2”部分中显示了php页面manage_team_teacher.php。在页面manage_team_teacher.php我有一个表单,如果我提交表单或点击我喜欢的链接再次在“item1_section2”部分显示结果。我对如何执行此操作感到非常困惑,因为所有内容都位于同一页面中(index.php)。我是PHP的新手,我需要你的帮助。你有什么建议?

正如你所看到的,我尝试了很多方法,但我遇到了问题:我尝试从URL获取页面名称(在类别中)。

<a href="index.php?category=manage_team_teacher2.php&amp;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>

1 个答案:

答案 0 :(得分:1)

您还需要检查网址是否存在

if(isset($_GET['category']) $$ $_GET['category'] ==bla ){

另外明智的是,如果任何人在网址中设置bla并且它不存在而不是它导致

Warning: include(): Failed opening '' for inclusion (include_path='blabal') on line bla