1

这是代码。

$result = mysql_query("SELECT * FROM situations");

echo "<table border='1'>
<tr>
<th>Case#</th>
<th>Cop(s)</th>
<th>Code</th>
<th>Vehicle/Person</th>
<th>Location</th>
<th>Division(s)</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
echo "<form action=situations.php method=post>";
echo "<tr>";
echo "<td>" . $row['Case#'] . " </td>";
echo "<td>" . "<input type=text name=cop value=" . $row['Cops']. " </td>";
echo "<td>" . "<input type=text name=sector value=". $row['Code'] . " </td>";
echo "<td>" . "<input type=text name=vehicle value=" . $row['Vehicle'] ." </td>";
echo "<td>" . "<input type=text name=location value="  .$row['Location'].  " </td>";
echo "<td>" . "<input type=text name=division value=" .$row['Division'].  " </td>";
echo "<td>" . "<input type=hidden name=hidden value=" .$row['Case #'] . " </td>";
echo "<td>" . "<input type=submit name=update_situations value=Update" . " </td>";
echo "</tr>";
echo "</form>";
  }
echo "</table>";

我有它,所以我可以更新它,但我的数据没有完全显示。EX:我会在位置上有“Dukes Blvd”,但它只会显示“Dukes”,请帮忙!我是 PHP、MySQL 的新手。

4

2 回答 2

0

我不同意 ntgCleaner 关于结束 PHP 的看法,尽管有时它需要额外的工作。如果您总是对引号使用相同的规则,那么这不是什么大问题,而且一段时间后您会立即识别出语法错误,或者当我得到一个时,这通常是我首先要寻找的东西。我总是以单引号开头,然后在 html 部分中添加双引号。

echo 'some code "quoted code" more code'.$variable;

您还可以使用反斜杠来标识引号 \' 以将其与错误状态分开。

于 2013-02-13T06:11:05.340 回答
0

您缺少引号;

while($row = mysql_fetch_array($result))
{
?>
<form action="situations.php" method="post">
<tr>
<td><?php echo $row['Case#']; ?></td>
<td><input type="text" name="cop" value="<?php echo htmlentities($row['Cops'], ENT_QUOTES, 'UTF-8') ; ?>"></td>
<td><input type="text" name="sector" value="<?php echo htmlentities($row['Code'], ENT_QUOTES, 'UTF-8'); ?>"></td>
<td><input type="text" name="vehicle" value="<?php echo htmlentities($row['Vehicle'], ENT_QUOTES, 'UTF-8'); ?>"></td>
<td><input type="text" name="location" value="<?php echo htmlentities($row['Location'], ENT_QUOTES, 'UTF-8'); ?>"></td>
<td><input type="text" name="division" value="<?php echo htmlentities($row['Division'], ENT_QUOTES, 'UTF-8'); ?>"></td>
<td><input type="hidden" name="hidden" value="<?php echo htmlentities($row['Case #'], ENT_QUOTES, 'UTF-8'); ?>"></td>
<td><input type="submit" name="update_situations" value="Update"></td>
</tr>
</form>
<?php
}
?>
</table>
于 2013-02-12T23:48:58.047 回答