newline in textarea

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stickman373
Forum Commoner
Posts: 30
Joined: Mon Jul 22, 2002 10:26 am

newline in textarea

Post by stickman373 »

How do i start a new line when printing to a textarea?

i Have this code:

Code: Select all

<?php $db = mysql_connect("localhost",$username,$password);
					mysql_select_db($database,$db);
					$query2 = "SELECT * FROM postnew ORDER BY id ASC"; 
					$result2 = mysql_query($query2); 
					while ($row = mysql_fetch_array($result2)) { 
			     	 echo '[b]Nick:[/b] '.$row['nick'].'     [b]Posted:[/b] '.$row['count'];
					 } mysql_free_result($result2);  ?>
So it goes through and gets all the nicknames and puts them along with their count, yet they are printed right next to each other i want them to print each nickname on a line of a textarea

how?
Rendez Vous
Forum Newbie
Posts: 1
Joined: Sun Dec 22, 2002 10:33 am

Post by Rendez Vous »

You need to use the New Line delimiter, which is \n, but you must place it within double quotes, so try the following:

Code: Select all

<?php
$db = mysql_connect("localhost",$username,$password); 
mysql_select_db($database,$db); 
$query2 = "SELECT * FROM postnew ORDER BY id ASC";  
$result2 = mysql_query($query2);  
while ($row = mysql_fetch_array($result2)) {  
echo "Nick: ".$row['nick']."     Posted: ".$row['count']."\n"; 
}
mysql_free_result($result2); 
?>
?>
stickman373
Forum Commoner
Posts: 30
Joined: Mon Jul 22, 2002 10:26 am

Post by stickman373 »

thanks a lot :o
Post Reply