The problem of displaying the entire line in the input field (in php)

I am trying to display an element from mysql table in input field type = text. Data is a string value. But I see only the first word of the whole line.

but if I am an echo element, I get the full string value.

My code is as follows:

  echo "Title: <input type=\"text\" name=\"title\" value=".$row['Title']."></input><br>"; 

Please let me know what I'm doing wrong here.

Best zeeshan

+3
source share
8 answers

You have not enclosed the text in quotation marks in the resulting HTML, try the following:

echo "Title: <input type=\"text\" name=\"title\" value=\"".$row['Title']."\"></input><br>";

or better yet

echo 'Title: <input type="text" name="title" value="'.$row['Title'].'"></input><br>';

which avoids double quotes.

+7
source

You are missing quotes around the attribute value:

echo "<input type=\"text\" name=\"title\" value=\"" . htmlspecialchars($row['Title'])  . "\"><br>"

htmlspecialchars, " <>. , </input>

+2

style="width:auto;" input, , , , Javascript. , ?

+1

:

?>
  <div>
  <label>Title: 
    <input type="text" name="title" value="<?php echo htmlspecialchars($row['Title'])?>">
  </label>
  </div>
<?php

, :

  • ,
  • ( , )

, , html, PHP. , .

, HTML, PHP PHP. HTML, , (validator.w3.org ), , PHP .

+1

, .

<input type="text" size="50">

50 .

nl2br(), , . , , , .

echo nl2br(row['Title']);
0

, , \n . = "" . , : str_replace ( "\n", ", $subject) . - " ". Htmlspecialchars ($ subject) , html.

0

, value , $row['Title'] , . :

echo 'Title: <input type="text" name="title" value="' . $row['Title'] . '" /><br />';
0

value = "'. $row [' Title '].' ' . .

0

Source: https://habr.com/ru/post/1711089/


All Articles