Php MySQL查询结果为空
我来这里已经有一段时间了,但这是我第一次发帖。下面是: 我正在为我的网站创建一个数据库。到目前为止,一切都很顺利。但是当创建.php来显示注释时,就好像根本不存在echo一样 代码运行得很好,因为我没有在任何可能的结果上得到任何错误。但在那些应该有结果的地方,什么都没有出现 这是我的密码:Php MySQL查询结果为空,php,mysql,Php,Mysql,我来这里已经有一段时间了,但这是我第一次发帖。下面是: 我正在为我的网站创建一个数据库。到目前为止,一切都很顺利。但是当创建.php来显示注释时,就好像根本不存在echo一样 代码运行得很好,因为我没有在任何可能的结果上得到任何错误。但在那些应该有结果的地方,什么都没有出现 这是我的密码: <?php $pickstory=$_POST['pickstory']; $result = mysql_query("SELECT name, comment
<?php $pickstory=$_POST['pickstory'];
$result = mysql_query("SELECT name, comment
FROM originalwork
WHERE story = '$pickstory'", $conexion);
if($fila= mysql_fetch_row($result)!=0){ ?>
<?php echo "<h6>Comments on $pickstory</h6>"; ?>
<table width="900">
<tr>
<td width="159" align="left" valign="top"></td>
<td width="729"></td>
</tr>
<?php while ($fila= mysql_fetch_row($result)) { ?>
<tr>
<td><?php echo "<h2>Name: $fila[0]</h2>"; ?></td>
<td><?php echo "<p>$fila[1]</p>"; }?></td>
</tr>
<?php } else { echo "<h5>No comments on $pickstory so far. Be the first!</h5>"; } ?>
</table>
<?php mysql_free_result($result); mysql_close(); ?>
您的代码格式设置非常糟糕。在这里
<?php
$pickstory = $_POST['pickstory'];
$result = mysql_query("SELECT name, comment
FROM originalwork
WHERE story = '$pickstory'", $conexion);
?>
<?php if(($fila = mysql_fetch_row($result)) !== false): ?>
<h6>Comments on <?=$pickstory?></h6>
<table width="900">
<tr>
<td width="159" align="left" valign="top"></td>
<td width="729"></td>
</tr>
<?php while (($row = mysql_fetch_row($result)) !== false): ?>
<tr>
<td><h2>Name: <?=$row[0]?></h2></td>
<td><p><?=$row[1]?></p></td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<h5>No comments on <?=$pickstory?> so far. Be the first!</h5>
<?php endif; ?>
</table>
<?php mysql_free_result($result); mysql_close(); ?>
回声在哪里?