2013-02-06 21 views
0

我只需要在div中放置一个<? include_once ("SOMETHING.PHP"); ?>。每次我把include_once放在div中,SOMETHING.PHP都不会显示在div里面!它会在div之外结束!<? include_once在div中?

这里是我的DIV + CSS代码:

#bcg { 
    -moz-border-radius:10px; /* for Firefox */ 
    -webkit-border-radius:10px; /* for Webkit-Browsers */ 
    border-radius:10px; /* regular */ 
    border-color:#000; 
    opacity:0.5; /* Transparent Background 50% */ 
    background-image:url(imgs/gray_jean.png); 
    height:500px; 
    width:450px; 
    margin-left:20px; 
    margin-top:15px; 
} 

,这是我如何把include_once的DIV中:

<div id="bcg"><?php include_once("something.php");?></div> 

我不知道我做错了!任何帮助,将不胜感激。

这是something.php

<?php 

$username=""; 
$password=""; 
$database=""; 

mysql_connect('localhost',$username,$password); 
@mysql_select_db($database) or die("Unable to select database"); 

$query="SELECT * FROM pages"; 

$result=mysql_query($query); 
$num=mysql_numrows($result); 

mysql_close(); 

?> 

<?php 

$i=0; 
while ($i < $num) { 
    $f1=mysql_result($result,$i,"pagebody"); 
?> 
<table width="350" border="0" cellspacing="0" cellpadding="0"> 
    <tr> 
     <td width="76"> 
      <font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font> 
     </td> 
    </tr> 
</table> 
<?php $i++; } ?> 
+9

什么是'something.php'? – hjpotter92

+0

你可以发布你想包含的PHP吗? – Phire

+1

你在调用'include_once(“something.php”);'也在其他地方?如果它的内容应该总是打印在这个位置,你可能想要调用'incldue(...);'。 –

回答

1

尝试捕获从包含脚本的输出在输出缓冲区中,然后呼应它。

<div id="bcg"> 
    <?php 
     ob_start(); 

     include_once("something.php"); 

     echo ob_get_clean(); 
    ?> 
</div> 
相关问题