Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem displaying the entire string in input box (in php)

Tags:

html

php

I am trying to display a element from mysql table in a input box type=text. The data is a string value. But i can see only the first word of the entire string.

but if i echo the element, i get the full string value.

My code looks like this:

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

Please let me know what am i doing wrong here.

Best Zeeshan

like image 379
Zeeshan Rang Avatar asked Dec 13 '22 03:12

Zeeshan Rang


1 Answers

You haven't enclosed the text in quotes in the resulting HTML, try this:

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

or better still

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

which avoids having to escape the double quotes.

like image 104
Julian Avatar answered Jan 02 '23 22:01

Julian