我创建了一个 slq 表(postgres db),我想打印字段“notes”的所有值,但 php 仅打印该值的第一个单词。
$name=trim($_POST['name']);
//select
if(!$query = @pg_query($conn,"SELECT notes FROM customer WHERE customer.name = '$name' "))
die("Errore nella query: " . pg_last_error($conn));
//print the content of field 'notes'
while($row = pg_fetch_array($query))
{
echo "<li>Notes: <input type=\"text\" placeholder=\"insert text\" id=\"note\" value=".$row['note']."></li>";
}
如果我的字段注释的值是 'lorem ipsum dixit'
php 仅打印 'lorem' 切断 'ipsum dixit'
为什么?
我找到了解决方案,我替换
echo "Notes: ";
与
注意:
谢谢大家
I create a slq table (postgres db) and i want to print all value of the field 'notes' but php print only first word of this value.
$name=trim($_POST['name']);
//select
if(!$query = @pg_query($conn,"SELECT notes FROM customer WHERE customer.name = '$name' "))
die("Errore nella query: " . pg_last_error($conn));
//print the content of field 'notes'
while($row = pg_fetch_array($query))
{
echo "<li>Notes: <input type=\"text\" placeholder=\"insert text\" id=\"note\" value=".$row['note']."></li>";
}
if the value of my field notes is 'lorem ipsum dixit'
php print only 'lorem' cutting off 'ipsum dixit'
Why?
i find the solution, i replace
echo "<li>Notes: <input type=\"text\" placeholder=\"insert text\" id=\"note\" value=".$row['note']."></li>";
with
<li>Note: <input type="text" placeholder="inserisci testo" id="note" value=" <?php echo $row['note'] ?>"></li>
thank you everyone
发布评论
评论(4)
我还将
echo "$row['notes']";
替换为echo $row['notes'];
i would also replace
echo "$row['notes']";
byecho $row['notes'];
你得到的东西
应该是这样的
You get something like
which should be
顺便说一句,不需要引号,应该是
echo $row['notes'];
BTW, there is no need of quotes, it should be
echo $row['notes'];
因为您正在获取数组,而不是关联数组,所以尝试使用 mysql_fetch_assoc 函数,它应该为您提供您正在寻找的行为。
Because you're fetching an array, not an associative array, try using the mysql_fetch_assoc function and it should give you the behavior you're looking for.