gpt4 book ai didi

php - MySQL 检索记录只给出每条记录中的第一个单词

转载 作者:搜寻专家 更新时间:2023-10-30 23:13:40 26 4
gpt4 key购买 nike

我有一个非常简单的图书数据库,只有 1 个表,有 9 个字段。几个字段中有多个单词,但是当我在表格中显示记录时,我只得到第一个单词。

我测试过使用:print_r($record['title']);

正如您将从数据库图像中看到的那样,它在表格外显示了完整的标题。我查看了代码,看不出问题出在哪里,但我知道这很可能是一个简单的解决方案。

<?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);

?>

Screenshot of DB and output

提前致谢

最佳答案

您的问题在于您创建 HTML 的方式:

你的代码是这样的:

<td><input type='text' name='title' disabled value=Several words in a title> </td>

但是你需要有这个:

 <td><input type='text' name='title' disabled value='Several words in a title'> </td>

(注意标题周围的引号。)

在您的值(value)观周围添加额外的引号。

echo "<td><input type='text' name='title' value='" . $record['title']  . "'> </td>";

关于php - MySQL 检索记录只给出每条记录中的第一个单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17100346/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com