时间:2013-02-06 23:39:25

标签: php html css

我只需要在div中放置一个<? include_once ("SOMETHING.PHP"); ?>。每次我把include_once放在div中时,SOMETHING.PHP都不会显示在div内!它会在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++; } ?> 

1 个答案:

答案 0 :(得分:1)

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

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

        include_once("something.php");

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