Php 如何按类别id包含两个文件

Php 如何按类别id包含两个文件,php,mysql,if-statement,include,Php,Mysql,If Statement,Include,我有一个文件要放在这个文件中,另外两个文件是动态的。主文件如下所示: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Gaming Ventus Let's Play - VLet's Play</title> <link rel="shortcut icon" href="images/favicon.ico"> <link rel=

我有一个文件要放在这个文件中,另外两个文件是动态的。主文件如下所示:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Gaming Ventus Let's Play - VLet's Play</title>
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="stylesheet" type="text/css" href="../styles/article_style_readmore.css">
<link rel="stylesheet" type="text/css" href="../../styles/styles_content_static_contact/styles_alltemplate_static_contact.css">
<link rel="stylesheet" type="text/css" href="../styles/readmore_mainbody_style.css">

<link rel="stylesheet" type="text/css" href="../../test/test2/Untitled-3.css">

</head>
<body>

<div id="wrapper">
  <div id="header">  
    <div id="top_header">
      <ul id="icons">
        <li><a href="http://youtube.com/" target="_blank"><img src="../../images/youtube-icon.png" alt="YT" width="32" height="32" /></a></li>
        <li><a href="http://facebook.com/" target="_blank"><img src="../../images/facebook-icon.png" alt="Fb" width="32" height="32" /></a></li>
        <li><a href="http://twitter.com/" target="_blank"><img src="../../images/twitter-icon.png" alt="Twit" width="32" height="32" /></a></li>
        <li><a href="http://google.com/" target="_blank"><img src="../../images/google-icon.png" alt="Goog" width="32" height="32" /></a></li>
        <li><a href="#" target="_blank"><img src="../../images/rss-icon.png" alt="Rss" width="32" height="32" /></a></li>
      </ul>        
    </div>

    <div id="bottom_header">
      <a href="../../index.php?page=home">
        <div id="logo"><img src="../../images/Ventus_Gaming_logo.png"></div>
      </a>
      <div id="search_bar">
        <form>
          <input type="text" id="search">
          <label for="search">Search</label>
        </form>
      </div>
    </div>
  </div>

  <div id="menu">
    <ul>
      <li><a href="../../index.php?page=home">Home</a></li>
      <li><a href="../../index.php?page=reviews">Reviews</a></li>
      <li><a href="../../index.php?page=news">News</a></li>
      <li><a href="../../index.php?page=videos">Videos</a></li>
      <li><a href="../../index.php?page=photos">Photos</a></li>
      <li><a href="../../content_static_main_body/contact.php?page=contact">Contact Us</a></li>
    </ul>
  </div>    

  <div id="main_body">
    <div id="main_left_nav">
  /****************************************************************\        
  <?php

    include('function_art_result_readmore.php');
    include('function_art_result_readmore_photos.php');

  ?>
  \****************************************************************/

    </div>

    <div id="right_nav">
      <div id="right_nav_about">
        About!
      </div>
      <div class="right_nav_others">
        Reviews!
      </div>
      <div class="right_nav_others">
        News!
      </div>
      <div class="right_nav_others">
        Videos!
      </div>
      <div class="right_nav_others">
        Photos!
      </div>
    </div>
  </div>

  <div id="footer">
    <p>Copyright Ventus Gaming</p>
  </div>
</div>

<?php
//Ayto einai to apotelesma otan patas to read more dhladh ta post mona tous
?>
</body>
</html>

游戏文图斯,我们来玩吧-我们来玩吧
搜寻
/****************************************************************\ \****************************************************************/ 关于 评论! 新闻! 视频! 照片! 版权所有文图斯游戏

所以在星号部分我有两个文件,我想包括。。。这些文件有mysql代码和php代码。所以我想把它们包括进来,像这样:

<?php 
  if ($CatID == 8) {
    include('function_art_result_readmore.php');       
  } else {
    include('function_art_result_readmore_photos.php');
  }
?>

但这是行不通的,只是举个例子。所以我想按类别id打开include文件,这样我就可以随时拥有这两个文件。 当然,如果有其他解决方案,我会接受:)


提前谢谢你

在请求中传递类别ID(使用以下代码获取或发布):


`

您从何处获得当前类别ID?我有一个数据库,其中有“类别ID”列。如果是您要求的。不工作:/它会在所有类别中打开此文件:function\u art\u result\u readmore\u photos.php。您能粘贴请求url吗?您的意思是?在请求参数GET/POST.中传递类别id。。(我在这个示例链接中作为GET-request-param传递)很抱歉,我不在pc中。所以我现在尝试一下,它工作得非常好。。。谢谢!如果需要,只需编辑以上答案即可完成:)
if(isset($_REQUEST['category_id']) &&  $_REQUEST['category_id'] == '8') {          
  include('function_art_result_readmore.php'); 
} else {  
  include('function_art_result_readmore_photos.php'); 
}