0

我下面的代码不起作用。

nisreen是 DB 的名称,表名是ana

我想要的是从数据库中读取 SWF 文件的路径,然后在网页上查看。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <title>Untitled 1</title>

        <?php

            $con =mysql_connect("localhost","root","");

            mysql_select_db("nisreen", $con);
            $result = mysql_query("SELECT * FROM ana LIMIT 1");
            while($row = mysql_fetch_array($result))
            {
                $row['title'];
            }

            echo '</head>';

            echo '<body>';
            echo $row; 
            echo '<object data="'.$row . "'";
            echo "type='application/x-shockwave-flash' width='600'  height='600'>";

            echo '</object>';
            echo '
    </body>    
</html>';
?>
4

1 回答 1

0

您没有将获取的数据分配给变量, $row 仅存在于该 while 循环的范围内。尝试类似的东西

<?php

    $con =mysql_connect("localhost","root","");

    mysql_select_db("nisreen", $con);
        $result = mysql_query("SELECT * FROM ana LIMIT 1");
         while($row = mysql_fetch_array($result))
         {
            $title = $row['title'];
            $path = $row['path'];   
         }

echo '</head>';

echo '<body>';
echo $title; 
echo '<object data="'.$path. "'";
echo "type='application/x-shockwave-flash' width='600'  height='600'>";

echo '</object>';
echo '
</body>

</html>';
?>
于 2012-09-24T21:49:14.433 回答