开发者

Textbox doesn't show properly

开发者 https://www.devze.com 2023-01-31 19:53 出处:网络
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???

Textbox doesn't show properly

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开发者_如何学Python 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!

0

精彩评论

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