By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Textarea Formatting

P: n/a
I am using a php html form with data which is loaded from a mysql
database. Three of the fields are textareas. The data loads into these
fields fine, except that the loaded text starts at what appears to be 2
or 3 tab characters to the left. See illustration:

+---------<this is a textarea object>---------+
| This is about the way that|
|the text loads from the database field. |
| |
| |
+---------------------------------------------+

It's almost as if there's a textarea "align" property which is set to
"center" by default unless otherwise explicitly stated.

Is there some setting in the wrap property that will fix this, or should
I be looking elsewhere?

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"bonehead" a écrit le 27/11/2003 :
I am using a php html form with data which is loaded from a mysql database.
Three of the fields are textareas. The data loads into these fields fine,
except that the loaded text starts at what appears to be 2 or 3 tab
characters to the left. See illustration:

+---------<this is a textarea object>---------+
| This is about the way that|
|the text loads from the database field. |
| |
| |
+---------------------------------------------+

It's almost as if there's a textarea "align" property which is set to
"center" by default unless otherwise explicitly stated.

Is there some setting in the wrap property that will fix this, or should I be
looking elsewhere?


Are you sure your variable is not modified before (with extra spaces)?
Consider using trim() on it before.

Try using CSS to format your Textarea element.
Jul 17 '05 #2

P: n/a
Jedi121 wrote:
Are you sure your variable is not modified before (with extra spaces)?
Consider using trim() on it before.


Thanks for replying. Actually I should have mentioned that I am using
trim(). I tested this by placing the contents of the variable in a table
cell *without* putting it in a textarea, and it behaves correctly, which
leads me to believe that there's something about the formatting of the
textarea itself that I'm not understanding.

Here's a code snippet:

//begin snippet

$user_comments = $query_data["comments"];

<tr>
<th align="center" width="30%">
Additional Comments Regarding This Form</th>
<td width="70%"><textarea name="comments" rows="3" cols="50">
<?php echo trim(htmlspecialchars($user_comments)) ?></textarea>
</td>
</tr>

//end snippet


Jul 17 '05 #3

P: n/a
It's probably indentation in your PHP code. If your code looks like this

<td>
<textarea>
<?php echo $something; ?>
</textarea>
</td>

then all that space in front of <?php... will end up in the textarea. Better do this

<td>
<textarea><?php echo $something; ?></textarea>
</td>

bonehead <se**********@here.org> wrote in message news:<3F**************@here.org>...
I am using a php html form with data which is loaded from a mysql
database. Three of the fields are textareas. The data loads into these
fields fine, except that the loaded text starts at what appears to be 2
or 3 tab characters to the left. See illustration:

+---------<this is a textarea object>---------+
| This is about the way that|
|the text loads from the database field. |
| |
| |
+---------------------------------------------+

It's almost as if there's a textarea "align" property which is set to
"center" by default unless otherwise explicitly stated.

Is there some setting in the wrap property that will fix this, or should
I be looking elsewhere?

Jul 17 '05 #4

P: n/a
On Wed, 26 Nov 2003 21:05:15 -0800, 'bonehead <se*********@here.org>
wrote:
Jedi121 wrote:
Are you sure your variable is not modified before (with extra spaces)?
Consider using trim() on it before.


Thanks for replying. Actually I should have mentioned that I am using
trim(). I tested this by placing the contents of the variable in a table
cell *without* putting it in a textarea, and it behaves correctly, which
leads me to believe that there's something about the formatting of the
textarea itself that I'm not understanding.


Remember that your browser will collapse contiguous whitespace. View
the source to see exactly what's being sent to the browser.

--
David ( @priz.co.uk )
The Internet Prisoner Database: http://www.priz.co.uk/ipdb/
The Tarbrax Chronicle: http://www.tarbraxchronicle.com/
Jul 17 '05 #5

P: n/a
Chung Leong wrote:
It's probably indentation in your PHP code. [snip] Better do this

<td>
<textarea><?php echo $something; ?></textarea>
</td>


Thanks! This worked!

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.