Reputation: 45
I'm trying to use php echo in a form text box to echo a value of an array, but the echo is only printing the first word of the phrase and ignoring everything after the first space and printing the rest outside of the quotation marks.
i.e want to echo
<value="Please help">
but it's currently only printing
<value="Please" help>
Code:
<input type="text" name="title" class="input-t" placeholder="Title" <?php if(isset($_GET['saletitle'])){echo "value=".$result['results'][$_GET['i']]['saletitle']."";} ?>>
Upvotes: 0
Views: 116
Reputation: 54831
Print your value with quotes:
echo 'value="'.$result['results'][$_GET['i']]['saletitle'].'"'
// ^-----------------------------------------------^
The reason is when you have
<input value=Please help id="some-id" class="class">
How can anyone tell what is the exact value
? Please
? Please help
? Please help id="some-id"
? That's why use quotes.
Upvotes: 1