我尝试从MySQL表中显示文本记录,以便编辑和更新它们。问题是文本不是完全取出的,而只是第一个单词(在文本中的第一个空格之前)。例如,作者John Doe'显示' John'对于书籍“Java编程”,它只显示“编程”这个词。我在代码中遗漏了一些内容,但我不知道:
session_start();
$user = $_SESSION['username'];
$pass = $_SESSION['password'];
if(isset($_POST ['Button1']))
{ $sql = "SELECT * FROM user WHERE idUser = '$user'";
$p = mysql_query($sql, $link);
echo "<table border=1>
<tr>
<th>Author</th>
<th>Book Title</th>
</tr>"
while($record=mysql_fetch_array($p)){
echo "<form action=edit.php method=post>";
echo "<tr>";
echo "<td>". "<input type=text name=author value=" .$record['author']. " size=40 ></td>";
echo "<td>". "<input type=text name=title value=" .$record['bookTitle']. " size=40 ></td>";
echo "</form>";}
echo "</table>";
}
答案 0 :(得分:1)
你的价值缺少报价:
echo '<td><input type=text name=author value="'.$record['author'].'" size=40 ></td>';