Line Breaks -- Content Management

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
zippants
Forum Newbie
Posts: 2
Joined: Tue Jan 28, 2003 12:06 pm

Line Breaks -- Content Management

Post by zippants »

I am trying to convert the carraige returns (of say, a 3 paragraph record) as stored onto the MySQL database to <br> in a php page to reflect 3 physical paragraphs opposed to a continous string (i.e. one paragraph). I read the http://www.php.net/manual/en/function.nl2br.php for the nl2br function, but I'm afraid I don't understand the code, much less if it is what I am looking for.

The information from the database is returned in the source with hard returns between each paragraph but it is simply ignored by the document as there are no <br> to denote breaks. Below is the code that calls the multi-paragraph record. Thank you very much for any help provided.

<?php require_once('Connections/connTest.php'); ?>
<?php
mysql_select_db($database_connTest, $connTest);
$query_rs = "SELECT * FROM content";
$rs = mysql_query($query_rs, $connTest) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
?>
<html>
<head>
<title>Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php do { ?>
<p><?php echo $row_rs['con']; ?> </p>
<?php } while ($row_rs = mysql_fetch_assoc($rs)); ?>
<p>&nbsp; </p>
</body>
</html>
<?php
mysql_free_result($rs);
?>
DeGauss
Forum Contributor
Posts: 105
Joined: Tue Oct 22, 2002 9:44 am
Location: Gainesville, FL

Post by DeGauss »

looks like another job for nl2br...
zippants
Forum Newbie
Posts: 2
Joined: Tue Jan 28, 2003 12:06 pm

right right

Post by zippants »

Right, I saw that article, I just don't follow how to implement into the page. Puh-lease... help! ;)
DeGauss
Forum Contributor
Posts: 105
Joined: Tue Oct 22, 2002 9:44 am
Location: Gainesville, FL

Post by DeGauss »

Erm...

Hmm...

Guessing from your code:

<?php echo nl2br($row_rs['con']); ?>

?

(That's the only echo statement i can find in your code)
Post Reply