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  |
------------------------------------------------------------------------
Link to comment
Share on other sites

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);
Link to comment
Share on other sites

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);
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.