我有两个页面,其中的内容是动态提供的,第一个 index.php 在我单击链接时包含另一个页面 person.php:
索引.php:
<?php include("db1.php");
define('WP_USE_THEMES', false);
require('blog/wp-blog-header.php');
$pages=array(
"person"=>"person.php"
);
?>
<!DOCTYPE html>
<head>
<title>Untitled Document</title>
<meta property="og:title" content=""/>
<meta property="og:url" content=""/>
<meta property="og:site_name" content=""/>
<meta property="og:description" content=""/>
</head>
<body>
<?
$sql="select id, name,title,image from persons where cat =10 ";
$rs=mysql_query($sql)or die(mysql_error());
if(list($id,$name,$title,$image)=mysql_fetch_array($rs)){
?>
<a href="?page=person&p=<? echo $id;?>" id="<? echo $id;?>" class="details">
<?
}
?>
<div class="twelve columns" id="persons">
<?
if($_GET["page"]=="")
$p="persons1";
else
$p=$_GET["page"];
if($pages[$p]!="")
include($pages[$p]);
else
echo "page not found ";
?>
</div>
</body>
</html>
第 2 页:person.php:
<? include("db1.php");?>
<?php
define('WP_USE_THEMES', false);
require('blog/wp-blog-header.php');
?>
<div class="row">
<div class="twelve columns">
<div class="eight columns">
<?
if(isset($_GET['p'])){
$id=str_replace('-',' ',(string)$_GET['p']);
$name1="";
$sql="select id, name,title,details,image,cat from persons where name ='".$id."' order by name asc";
$rs=mysql_query($sql)or die(mysql_error());
if(list($id,$name,$title,$details,$image,$cat)=mysql_fetch_array($rs)){
$a=$name;
?>
<h3><? echo $name;?></h3>
<h5><? echo $title;?></h5>
<p align="justify">
<img alt="<? echo $name;?>" src="images/persons/<? echo $image?>" title="<? echo $name;?>" style="float:right; margin-left:15px;" />
<? echo $details;?>
</p>
<?
}
}
?>
包含页面时如何在 index.php 的元标记中使用 person.php 页面的值?