0
我有哪些内容正在被送入动态两页,第一个index.php文件包括其他页面person.php当我点击链接:如何在php中使用其他元标记的页面值?
的index.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>
<?
}
}
?>
当包括页面如何使用person.php页面的值的index.php的meta标签?
哪里是在要使用'person.php'的数据?在它的表面上,这应该是非常简单的,因为'person.php'不使用从index.php继承的任何数据,因此它可以在脚本的顶部运行并且结果被捕获到输出中缓冲区,稍后再回声。另外,让我向你介绍一个叫做[Bobby Tables]的老敌人(http://bobby-tables.com/) – DaveRandom 2012-08-01 15:54:12
我想用($ name,$ title,$ details,$ image)结果MySQL在index.php的元标记中的person.php中选择,问题是人应该被包含在头标记之后,因为我的页面结构 – 2012-08-01 15:57:52
好吧,我不想只给你答案,直到你已经自己尝试过了,或者你不会学到任何东西,但以下是你需要完成的所有信息:你需要将包含文件的逻辑移动到index.php的顶部,高于''。您需要使用[输出缓冲](http://php.net/ob-start)来捕捉'person.php'的输出,以便它可以在正确的位置输出。一旦包含文件,它创建的变量将在index.php中可用。如果你对此有任何疑问,我会很乐意帮助你,但先去玩一下。 – DaveRandom 2012-08-01 16:07:59