我有一个相当简单的图书数据库,只有 1 个包含 9 个字段的表。几个字段中有多个单词,但是当我在表格中显示记录时,我只得到第一个单词。
我已经使用以下方法进行了测试:print_r($record['title']);
正如您从 DB 的图像中看到的那样,它在表格之外显示完整的标题。我浏览了代码,看不出问题出在哪里,但我知道它很有可能是一个简单的解决方案。
<?php
include "mysqlconnect2.php";
mysql_select_db('MySite',$conx);
if (isset($_POST['update'])){
$updateQuery = "UPDATE books SET id='$_POST[id]', section='$_POST[section]', topic='$_POST[topic]', subtopic='$_POST[subtopic]', title='$_POST[title]', isbn13='$_POST[isbn13]', isbn10='$_POST[isbn10]', cdincluded='$_POST[cdincluded]', notes='$_POST[notes]' WHERE id='$_POST[id]'";
mysql_query($updateQuery, $conx);
};
$sql = "SELECT `id`,`section`,`topic`,`subtopic`,`title`,`isbn13`,`isbn10`,`cdincluded`,`notes` FROM books";
$mydata = mysql_query($sql,$conx);
echo "<table border=1>
<tr>
<th>id</th>
<th>Section</th>
<th>Topic</th>
<th>Subtopic</th>
<th>Title</th>
<th>Isbn13</th>
<th>Isbn10</th>
<th>Cd Included</th>
<th>Notes</th>
<th>Update</th>
</tr>";
while ($record = mysql_fetch_array($mydata)){
print_r($record['title']);
echo "<form action='books3.php' method='post'>";
echo "<tr>";
echo "<td>" . "<input type='text' name='id' disabled value=" . $record['id'] . "> </td>";
echo "<td>" . "<input type='text' name='section' value=" . $record['section'] . "> </td>";
echo "<td>" . "<input type='text' name='topic' value=" . $record['topic'] . "> </td>";
echo "<td>" . "<input type='text' name='subtopic' value=" . $record['subtopic'] . "> </td>";
echo "<td>" . "<input type='text' name='title' value=" . $record['title'] . "> </td>";
echo "<td>" . "<input type='text' name='isbn13' value=" . $record['isbn13'] . "> </td>";
echo "<td>" . "<input type='text' name='isbn10' value=" . $record['isbn10'] . "> </td>";
echo "<td>" . "<input type='text' name='cdincluded' value=" . $record['cdincluded'] . "> </td>";
echo "<td>". "<input type='text' name='notes' value=" . $record['notes'] . "> </td>";
echo "<td>" . "<input type='submit' name='update' value='Update'>";
echo "</td>";
echo "</tr>";
echo "</form>";
}
echo "</table>";
mysql_close($conx);
?>
提前致谢