开发者

Why php do not print all content of field text type

开发者 https://www.devze.com 2023-02-28 08:15 出处:网络
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.

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(!开发者_JS百科$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


i would also replace echo "$row['notes']"; by echo $row['notes'];


You get something like

 <input ... value=lorem ipsum>

which should be

 <input ... value="lorem ipsum">


BTW, there is no need of quotes, it should be echo $row['notes'];


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消