Forum Moderators: coopster

Message Too Old, No Replies

Textarea Semicolon String

how to separate string in textarea

         

bbunny

8:07 pm on Nov 15, 2007 (gmt 0)

10+ Year Member



I have a textarea that is used to 'put' database values based on a selection from another textarea. They are separate values in mysql and when retrieved are email addresses which are semicolon separated and need to be simply listed like:

aol@aol.com;
yahoo@yahoo.com;
gmail@gmail.com

instead of aol@aol.com;yahoo@yahoo.com;gmail@gmail.com

Not sure if this is PHP applicable or if it should be accomplished by CSS, javascript, etc... I am assuming this is an easy fix and I am just missing it. Below is part of the code.

<textarea name="email" cols="40" rows="10" id="email" type="text"><?php do {?><?php echo $row_record1['email'], $row_record1['email2'], $row_record1['email3']?><?php } while ($row_record1 = mysql_fetch_assoc($record1));?></textarea>

ayushchd

8:11 pm on Nov 15, 2007 (gmt 0)

10+ Year Member



Won't this do?
<textarea>
<?php
while ($row_record1 = mysql_fetch_assoc($record1)) {
echo $row_record1['email'] . "<br>";
}
?>
</textarea>

ayushchd

8:28 pm on Nov 15, 2007 (gmt 0)

10+ Year Member



Well after some reading..i just found that you cannot use anything inside textarea to be rendered as markup tags..

So, its better you use something else...or else I juss came up with this not so ugly code...but is doing the work :

<textarea>
<?php
while ($row_record1 = mysql_fetch_assoc($record1)) {
echo $row_record1['email'] . "
";
}
?>
</textarea>

Just added an extra line after every email address display!

eelixduppy

8:32 pm on Nov 15, 2007 (gmt 0)



You should be able to concatenate a carriage return and new line character to the end and it should work:

echo $row_record1['email']."\r\n";