PHP Foreach语句问题.返回多行

Dan*_*lea 5 html php mysql

我是一名PHP初学者,最近我的源代码出现了问题.

这里是:

   <html>
    <head>
        <title>
            Bot
        </title>
        <link type="text/css" rel="stylesheet" href="main.css" />
    </head>
    <body>
        <form action="bot.php "method="post">
            <lable>You:<input type="text" name="intrebare"></lable>
            <input type="submit" name="introdu" value="Send">
        </form>
    </body>
</html>
<?php
//error_reporting(E_ALL & ~E_NOTICE);
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("robo") or die(mysql_error());

$intrebare=$_POST['intrebare'];
$query = "SELECT * FROM dialog where intrebare like '%$intrebare%'"; 
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
?>
<div id="history">
<?php       
        foreach($row as $rows){ 
            echo "<b>The robot says: </b><br />";
            echo $row['raspuns'];
            }
?>
</div>
Run Code Online (Sandbox Code Playgroud)

它返回结果6次.

当我这样做时出现了这个问题,foreach因为我想在每次SQL查询后逐个地将结果卡在页面上.

你能告诉我似乎有什么问题吗?谢谢!