Languages :: PHP :: PHP & Textarea |
|||
| By: PHP newbee |
Date: 25/09/2003 00:00:00 |
Points: 300 | Status: Answered Quality : Excellent |
|
I am having trouble with a form I have created. I use the following line of code: <td><textarea name="message" cols="50" rows="10" wrap=physical><? echo $message; ?></textarea></td> </tr> To send a large message to a mysql database (approximately 600 letters). when I extract it from the database Iuse this code to display the results: <td><font size="2"><b>Message:</b> <? echo $guest['guest_message']; ?></font></td> For some reason, the message is not wrapping and making my form look bad. I have tried with wrap=physical, virtual, off, on, hard, soft, everything you can imagine. Why wont this display properly? Thanks... |
|||
| By: Michael701 | Date: 25/09/2003 04:00:00 | Type : Comment |
|
| why not use a <textarea> to display the results, you can always use the 'readonly' attribute to prevent changes on the displayed page. |
|||
| By: VGR | Date: 25/09/2003 04:33:00 | Type : Comment |
|
| 1) your message may contain HTML codes... Try to print htmlspecialchars($guest['guest_message']); ... 2) beware of magic_quoting. so I suggest to try : <td><font size="2"><b>Message:</b> <? echo htmlspecialchars($guest['guest_message']); ?></font></td> |
|||
| By: Zvonko | Date: 25/09/2003 17:09:00 | Type : Comment |
|
| Add a cell width for the display: <td width="150"><font size="2"><b>Message:</b> <? echo $guest['guest_message']; ?></font></td> |
|||
| By: VGR | Date: 25/09/2003 17:30:00 | Type : Comment |
|
| use the textarea, it works just fine |
|||
| By: Zvonko | Date: 25/09/2003 17:35:00 | Type : Comment |
|
| Ok, a width of 150 is not simmelar to cols=50. Better use 400 px. Like this: <td width="400"><font size="2"><b>Message:</b> <? echo $guest['guest_message']; ?></font></td> |
|||
| By: PHP newbee | Date: 25/09/2003 18:12:00 | Type : Comment |
|
| These are all great solution but none of them worked. I am attaching the full code here. Thanks.... Form to add the entry: <form method="post" action="add_entry.php"> <table> <tr> <td valign="top">Your Name:</td> <td><input type="text" name="name" SIZE="50" maxlength="50" value="<? echo $name; ?>"></td> </tr> <tr> <td valign="top">Your Email:</td> <td><input type="text" name="email" SIZE="50" maxlength="50" value="<? echo $email; ?>"></td> </tr> <tr> <td valign="top">Subject:</td> <td><input type="text" name="subject" SIZE="50" maxlength="50" value="<? echo $email; ?>"></td> </tr> <tr> <td valign="top">Enter Message:</td> <td><textarea name="message" cols="50" rows="10" wrap="Physical"><? echo $message; ?></textarea></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Add Entry"></td> </tr> </table> </form> Code to output the results: while ($guest = mysql_fetch_array($guests)) { ?> <table border="1" bordercolor="#CC3300" cellspacing="0" cellpadding="0"><tr><td> <table width="640" cellpadding="0" cellspacing="0"> <tr> <td> <table width="640" cellpadding="3" cellspacing="0"><tr> <td bgcolor="#CC3300"><font size="3" color="#ffffff"><b><? echo $guest['guest_subject']; ?> posted by <? echo $guest['guest_name']; ?></b> </font></td> </tr></table> </td> </tr> <tr> <td> <table width="640" cellpadding="0" cellspacing="5"> <tr> <td><font size="2"><b>Email:</b> <A HREF="mailto:<? echo $guest['guest_email'];?>"><? echo $guest['guest_email'];?></a></font> <?php //***************************************************************** //* Format timestamp on the record in "MM/DD/YY HH:MM xm" format //***************************************************************** $timestamp = $guest['guest_time']; $year = substr($timestamp,0,4); $mon = substr($timestamp,4,2); $day = substr($timestamp,6,2); $hour = substr($timestamp,8,2); $min = substr($timestamp,10,2); $sec = substr($timestamp,12,2); $formatted_date = date(" m/d/y g:i a",mktime($hour,$min,$sec,$mon,$day,$year));?> <font size="2"><b>Date:</b> <? echo $formatted_date; ?></font> </td> </tr> <tr> <td><font size="2"><? echo nl2br($guest['guest_message']); ?></font></td> </tr> </table> </td> </tr> </table> </td></tr></table> <?php } ?> |
|||
| By: Zvonko | Date: 25/09/2003 18:19:00 | Type : Comment |
|
| This line does not have a cell width: <td><font size="2"><? echo nl2br($guest['guest_message']); ?></font></td> Change it to: <td width="400"><font size="2"><? echo nl2br($guest['guest_message']); ?></font></td> |
|||
| By: PHP newbee | Date: 25/09/2003 18:35:00 | Type : Comment |
|
| I have tried this already and did not work. This is the output I get from this fix: <td width="640"><font size="2">Trying to eliminate any wrapping problems that would make this guestbook look bad. **********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************8</font></td> |
|||
| By: VGR | Date: 25/09/2003 18:52:00 | Type : Answer |
|
| wrapping can't happen if you've no spaces between words, even with "hard" |
|||
| By: Zvonko | Date: 25/09/2003 18:57:00 | Type : Comment |
|
So far I have only this: <TD Width=640 style="word-break: break-all;"><font size="2">Trying to eliminate any wrapping problems that would make this guestbook look bad. **********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************8</font></td></tr> |
|||
| By: PHP newbee | Date: 25/09/2003 19:17:00 | Type : Comment |
|
| I am a dork... didn't realize this about word wrap. Sorry to be racking all of yer brains! |
|||
| By: VGR | Date: 25/09/2003 19:17:00 | Type : Comment |
|
| not mine :D huh huh huh such things happen |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








