0

I have a form that I pre-fill with my database data. It is working perfectly for all my input. I have a text (that I enter in my database using a textarea). But when I am using the following the text does show in the text area (if I change it to input it is working but I do not have several lines and column allowed with textarea)

<textarea 
    rows="4"
    class="form-control" 
    name="roster_description" 
    id="roster_description" 
    placeholder =
        <?php if ($description_roster){
                echo '"'.$description_roster.'"'; 
            } else {
                echo "";
            }?>>
</textarea>

any ideas?

6
  • What is the output of your PHP? Commented Nov 25, 2014 at 13:50
  • this is a shot in the dark, remove that newline, and put it in one line instead: ?>></textarea> maybe related stackoverflow.com/questions/10585759/… Commented Nov 25, 2014 at 13:53
  • This code should work. Can you post the code before the textarea definition? Commented Nov 25, 2014 at 13:57
  • @uʍopǝpısdn $description_roster is a string 'a team composed of players' Commented Nov 25, 2014 at 14:03
  • Not a solution, but you might want to escape the description first, in case you have a description like Dwayne "The Rock" Johnson. Commented Nov 25, 2014 at 14:04

3 Answers 3

1

Just tested it and it works:

<textarea 
    rows="4"
    class="form-control" 
    name="roster_description" 
    id="roster_description" 
    placeholder = "<?php if ($description_roster) echo $description_roster;?>">
</textarea>
Sign up to request clarification or add additional context in comments.

1 Comment

This isn't the problem. Also the question had a check if description_roster exists which is a good thing. So your solution is worser then the question self.
1

The issue was that your statement:

echo "";

doesn't produce quotation marks - it produces the empty string. What you want is to replace this with:

echo '""';

which will produce placeholder=""> instead of placeholder=>.

Comments

0

Ok no clue why but the following is working:

<textarea class="form-control" id="description_roster" 
          name="description_roster" rows="4"
          placeholder=<?php
                         if ($description_roster){
                             echo '"'.$description_roster.'"';
                         } else {
                             echo "";
                         }
                       ?>
></textarea>

Thanks to those who had a look

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.