文本框无法正确显示

texbox

I'm using PHP to retrieve the data from a database.

Every time I retrieve it from database it doesn't show the whole letters. It's being removed off after space???

I want like the first text box, show all the letters

both code doesn't work

<input type="text" class="textinput"  value=' . $r['newsletter_title'] . '>

<input type="text" class="textinput"  value=' . htmlspecialchars($r['newsletter_title']) . '>

I checked the database it's showing the whole letters "80% sale On Day"

Does anyone knows what causes this? Any solution please!!!

You need to quote the value (and use htmlspecialchars):

<input 
    type="text" 
    class="textinput" 
    name="newsletter_title" 
    id="newsletter_title" 
    value="' . htmlspecialchars($r['newsletter_title']) . '" 
    />

Which generates:

<input 
    type="text" 
    class="textinput" 
    name="newsletter_title" 
    id="newsletter_title" 
    value="80% sale On Day" 
    />

Otherwise you're generating invalid html/xml (which is why it isn't working)...

Type escaping the content with htmlspecialchars() - http://www.php.net/manual/en/function.htmlspecialchars.php

The value of the value-attribute is not enclosed in quotes. Enclose the value of the value attribute in quotes. Use your browser to look at the HTML that you generate. Don't just look at how your browser renders that HTML.

<input type="text" class="textinput" name="newsletter_title" id="newsletter_title" style="width:500px;" value="' . htmlspecialchars($r['newsletter_title']) . '">

Problem Solved. Thanks guys!