Jump to content

Separating the paragraphs question (Help needed)


Iyad

Recommended Posts

Hi,

I have a table like you see bellow written in MySQL. Like usual, I write an insert query code in PHP. When I fill in the table, precisely fill in ‘Content’ field. I use ENTER < to separate line between paragraphs. But when I preview the page, the ENTER < doesn’t appear. The whole paragraphs is join together.

Was this topic have ever discussed before?. I hope someone here will help me.

Thanks,

-Iyad

------------------------------------------------------------------------
|  articel_id  |        topics        |    writer    |    content  |    date    |
------------------------------------------------------------------------
|        1      |  Global warming    |    Erian    | dummy text | 30-12-06  |
------------------------------------------------------------------------
hi Iyad,

The problem is not the "enter to DB" part.  It is the display to html.
Your text stored exactly as you typed in the content field.  However, when you paste this text into html, browser recognized a new line as a space, so your text look like it is on 1 line.

It is very common to use this function to replace all new line with html break:

$textToDisplayOnBrowser = nl2br($textRetrievesFromDB);
This is the page code. Where do I put that: $textToDisplayOnBrowser = nl2br($textRetrievesFromDB);


<?php require_once('Connections/articles.php'); ?>
<?php
mysql_select_db($database_articles, $articles);
$query_record_articles = "SELECT * FROM article_categories ORDER BY article_id ASC";
$record_articles = mysql_query($query_record_articles, $articles) or die(mysql_error());
$row_record_articles = mysql_fetch_assoc($record_articles);
$totalRows_record_articles = mysql_num_rows($record_articles);
?>
<html>
<head>
<title>ARTICLES</title>
</head>
<body>
<p>No. : <?php echo $row_record_articles['article_id']; ?><br>
  Topics : <?php echo $row_record_articles['topics']; ?><br>
  Writer : <?php echo $row_record_articles['writer']; ?><br>
  Content :  <?php echo $row_record_articles['content']; ?><br>
  Date :
<?php echo $row_record_articles['date']; ?></p>
</body>
</html>
<?php
mysql_free_result($record_articles);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.