GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 21-Jul-2003, 06:30
zuzupus zuzupus is offline
Junior Member
 
Join Date: Jul 2003
Posts: 70
zuzupus is an unknown quantity at this point

wordwrap in text


hi,
i got problem in wordwrap tetxarea
this textarea fetching from database
PHP Code:

$query = "SELECT text FROM t_emp ";
$result = mysql_query($query) or die("Query failed: Fetch all rows"); 


//textarea in form
Code:
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 width=100% name="rsTable" id=rsTable cols=11> <td align="center"> <textarea name="text" style="width:100px:" class="mybar" id="tar" cols="20" rows="1" onfocus="tarea();" onblur="tarea();" title=""></textarea> </td>
PHP Code:

<? while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$output = wordwrap($line['text'], 15,"\n", 1);?>
//printing in form
<td align="center"><div style="width:100px:"><?echo "$output\n";?></div></td>

let say i type some text in textarea
$text = "The quick brown fox jumped over the lazy dog.";
but as result im not getting any change it prints the whole line no wordwrap is working is there error in table width=100% and textarea width=100px as i m having 11 cols in form and i used px only in textarea is this is right way
whast the diff. between px and %

i want something like example2 in the link
www.php.net

is some width i have to change in below width of cols
<tr bgcolor="#cccccc">
<th nowrap>Datum</th>
<th nowrap>Von</th>
<th nowrap>Bis</th>
<th nowrap>Kunde</th>
<th nowrap>Projekt</th>
<th nowrap>H-Vorgang</th>
<th nowrap>U-Vorgang</th>
<th nowrap>Text</th>
<th nowrap>IST</th>
<th nowrap>Soll</th>
<th nowrap>Status</th>
<th nowrap>&nbsp;</th>
</tr>

thanks for understanding
  #2  
Old 21-Jul-2003, 07:52
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
OK, ignoring your code, I quickly wrote a sample PHP page that I think, will help you figure out your issue with wordwrap and a fixed (sized) textarea. If my assumption is wrong please let me know.

Copy and save the following php 'script' to, let's say test.php:
PHP Code:

<?php
// FILENAME: test.php
// ------------------
// save this file as 'test.php' and view the page with your favourite browser
// to see if the text area works like you want it to.

// sample text for the textarea.
$text = 'Aaaaaaaaaaaaargh! The quick brown fox jumped over the lazy dogs... again!';

// let's wrap any word longer than 9 characters in the textarea!
$text = wordwrap( $text, 9, "\\n", 1 );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Textarea Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<!-- imagine the table taking up the entire width of the reader's screen
  iow, 100% width -->
<table border="1" style="width:100%" cols="3">
  <tr>
    <!-- with 3 main columns -->
    <th>Column 1</th>
    <th>Column 2</th>
    <th>Column 3</th>
  </tr>
  <tr>
    <td style="vertical-align:top">A cell in Column 1</td>
    <!-- We add a simple form with a textarea here -->
    <td style="vertical-align:top; text-align:center;">
      <form>
        <!-- the textarea size is controlled by the style attribute; i.e.
            width:100px; and height:100px -->
        <textarea name="sample" id="sample" style="width:100px; height:100px;" cols="9"><?php echo $text; ?></textarea>
      </form>
    </td>
    <td style="vertical-align:top">A cell in Column 3</td>
  </tr>
</table>
</body>
</html>

The difference between % and pixels (px) values are % will take the size (width or height) off the containing element. In other words, if the available screen width is 500px, an attribute width="100%" will make that element have a width of 500px, (which is 100% off 500px)..
  #3  
Old 21-Jul-2003, 08:02
zuzupus zuzupus is offline
Junior Member
 
Join Date: Jul 2003
Posts: 70
zuzupus is an unknown quantity at this point
thanks alot !well for form based \n wont works

$text = 'Aaaaaaaaaaaaargh! The quick brown fox jumped over the lazy dogs... again!';
$text = wordwrap( $text, 9, "<br />", 1 );
echo $text;


this works perfectly

thanks
 
 

Recent GIDBlogA Week in Kuwait by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CD Burner Help - Power Calibration Error.... JonBoy420 Computer Hardware Forum 111 17-Apr-2008 15:58
Manipulating text Files k209310 C++ Forum 0 17-Nov-2003 10:23
CD Buring Failed skanth2000 Computer Hardware Forum 1 15-Nov-2003 03:52
text field problm zuzupus Web Design Forum 3 04-Sep-2003 05:18
Scrolling Text Ads - Free advertising on other peoples sites jrobbio Advertising & Affiliates Forum 0 19-Feb-2003 00:00

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:22.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.