包括数据库中的页面

时间:2014-02-09 07:40:52

标签: php mysqli include

我想在一个页面中包含我的所有页面内容。每个页面的内容都在div中。如何使我的数据库包含所有页面的内容?有些页面有照片,api等。

主题数据库

id menu_name位置可见 1 Website_Pages 1 1 2数据库2 0

页面数据库

id subject_id menu_name位置可见 1 1模板2 1 1 2 1 template_replace_oo 2 1 3 1 photo_gallery 3 1

的index.php

<div id ="main">
        <?php 

        $query = "SELECT * ";
        $query .= "FROM subjects ";
        $query .= "WHERE id = 1 ";
        $query .= "ORDER BY position ASC";
        $result = mysqli_query($connection, $query);
        confirm_query($result);

        while($subject = mysqli_fetch_assoc($result)) {

        ?>



        <?php

        $query = "SELECT content ";
        $query .= "FROM pages ";
        $query .= "WHERE visible = 1 ";
        $query .= "AND subject_id = 1 ";
        $query .= "ORDER BY position ASC";
        $page_set = mysqli_query($connection, $query);
        confirm_query($page_set);

       $output = "<div>";


       while($page = mysqli_fetch_assoc($page_set)) {

          $output .=  include($page['menu_name']."php");

            $output .= "</div>";
  // INDEX PAGE IS FOR PUBLIC DISPLAY !  
   // parse the navigation section that i sent into functions.php
   return $output;
       }
        }
   ?>

0 个答案:

没有答案
相关问题