PHP Formated Text Diplay: How do I echo linebreaks, paragraphs, bolding etc

Hi.

Keep in mind I am a beginner - using Dreamweaver server behaviors

I am using a form with Text Edit features to insert user articles. The problem is the text is displayed without lined breaks or any form of formatting. See below my php:
[php]<?php echo $row_NewsDisp['news_article'];?>[/php]

If you can just insert the required tags where they are needed - ie.


Thanks

You format it like any other page. You can do the html inside or outside the php, personally, i like doing it outside.

<?php echo $row_NewsDisp['news_article'];?>


richei.

Appreciate your feedback but tried it several times not working here his the php again

THE INSERT

[php]<?php echo $row_FormDispNews['news_article']; ?>[/php]

THE DISPLAY:

[php]

<?php echo $row_NewsDisp['news_article'];?>
[/php]
  1. The CSS is not showing
  2. No line-breaks whatsoever

Thanks

if this is an RTF file, you’ll need and RTF to HTML parser. If you just need linebreaks. Use the PHP Explode() function to break into an array of lines and use \n or \r\n as the delimiter.

aztech!Thanks for the feedback but I am a complete beginner, amateur to PHP. Your reply just flew over my heard “phew!”

I am not at all familiar with the PHP language I use Dreamweaver Behaviors to click and insert php… here my code, can you just insert the line formatting text where it goes:

[php]

<?php echo $row_NewsDisp['news_article'];?>
[/php]

Thanks

RTF stands for Real Text Format. This type of file embeds non-printing characters into a document that allow for formatting. All word processors use the strict RTF format or a variant of it.

HTML doesn’t know about these formatting characters. HTML has it’s own formatting methodology using tags, you provided two in your question.

A parser grabs selected and useful data from a file. This data can now be used as we wish, like turning into HTML.

Google RTF to HTML parser, you’ll find some.

Now, don’t do any of this unless it is an RTF file. There is a good chance some or all formatting was stripped from your file as it was being saved. You need to verify you have what you are expecting to get.

as far as I know, dreamweaver doesn’t save as RTF.

@Alex: What do you have in CSS that should edit how something is displayed?

@RaythXC

Don’t think Aztech4mac gets me, but I know experts assume everyone understands on their level- I don’t get his advice.

Moving right along, I’m still sitting with the challenge, my Display text still doesn’t have line breaks or show paragraphs.

The one person close to the solution is Rechei…

<?php echo $row_NewsDisp['news_article'];?>


I remember using a similar method but I can’t remember how - it had to do with inserting the


tag inside the echo statement.

Somebody help!

[php]

<?php echo "

".$row_NewsDisp['news_article']."


"; ?>

[/php]

What I meant was, when you said:

1. The CSS is not showing 2. No line-breaks whatsoever
You haven't actually shown us any CSS.

Also the div tags here seem pretty meaningless:

[php]

<?php echo $row_NewsDisp['news_article'];?>
[/php]

RaythXC

<?php echo "

".$row_NewsDisp['news_article']."


"; ?>

Not working. Is there anymore info I can give you - the whole page perhaps.

Hate it when something so simple doesn’t seem to work. The very page has that code because I inserted text and submitted. I’m going to ‘view source’ but in the meantime friends, lets help each other…today, me!

[php]<?php require_once('../Connections/Drjacha.php'); ?>

<?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $currentPage = $_SERVER["PHP_SELF"]; $maxRows_NewsDisp = 5; $pageNum_NewsDisp = 0; if (isset($_GET['pageNum_NewsDisp'])) { $pageNum_NewsDisp = $_GET['pageNum_NewsDisp']; } $startRow_NewsDisp = $pageNum_NewsDisp * $maxRows_NewsDisp; mysql_select_db($database_Drjacha, $Drjacha); $query_NewsDisp = "SELECT news_ID, news_title, news_date, news_article FROM news ORDER BY news_ID DESC"; $query_limit_NewsDisp = sprintf("%s LIMIT %d, %d", $query_NewsDisp, $startRow_NewsDisp, $maxRows_NewsDisp); $NewsDisp = mysql_query($query_limit_NewsDisp, $Drjacha) or die(mysql_error()); $row_NewsDisp = mysql_fetch_assoc($NewsDisp); if (isset($_GET['totalRows_NewsDisp'])) { $totalRows_NewsDisp = $_GET['totalRows_NewsDisp']; } else { $all_NewsDisp = mysql_query($query_NewsDisp); $totalRows_NewsDisp = mysql_num_rows($all_NewsDisp); } $totalPages_NewsDisp = ceil($totalRows_NewsDisp/$maxRows_NewsDisp)-1; $queryString_NewsDisp = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_NewsDisp") == false && stristr($param, "totalRows_NewsDisp") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_NewsDisp = "&" . htmlentities(implode("&", $newParams)); } } $queryString_NewsDisp = sprintf("&totalRows_NewsDisp=%d%s", $totalRows_NewsDisp, $queryString_NewsDisp); ?> Untitled Document .MainContent { font-family: Verdana, Geneva, sans-serif; font-size: 11px; color: #CCC; font-style: normal; } .PicBoder_white { border-top-width: thick; border-right-width: thick; border-bottom-width: 12px; border-left-width: thick; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #999; border-right-color: #999; border-bottom-color: #999; border-left-color: #999; } body { background-color: #333; }
    <?php do { ?>
      <tr>
        <td><?php echo $row_NewsDisp['news_title']; ?></td>
        </tr>
      <tr>
        <td class="MainContent"><?php echo $row_NewsDisp['news_date']; ?></td>
        </tr>
      
      
      <tr>
        <td class="NewsArticle"><?php echo "<p style='font-weight: bold;'>".$row_NewsDisp['news_article']."</p><br/>"; ?>
        
    
        </td>
        </tr>
      <tr>
        <td class="NewsArticle"><table border="0" cellpadding="5">
      <tr>
        <td width="102"><?php if ($pageNum_NewsDisp > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_NewsDisp=%d%s", $currentPage, 0, $queryString_NewsDisp); ?>">First 5 Articles</a>
            <?php } // Show if not first page ?></td>
        <td width="130" bgcolor="#999999"><?php if ($pageNum_NewsDisp > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_NewsDisp=%d%s", $currentPage, max(0, $pageNum_NewsDisp - 1), $queryString_NewsDisp); ?>">Previous 5 Articles</a>
            <?php } // Show if not first page ?></td>
        <td width="103"><?php if ($pageNum_NewsDisp < $totalPages_NewsDisp) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_NewsDisp=%d%s", $currentPage, min($totalPages_NewsDisp, $pageNum_NewsDisp + 1), $queryString_NewsDisp); ?>">Next 5 Articles</a>
            <?php } // Show if not last page ?></td>
        <td width="56" bgcolor="#006699"><?php if ($pageNum_NewsDisp < $totalPages_NewsDisp) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_NewsDisp=%d%s", $currentPage, $totalPages_NewsDisp, $queryString_NewsDisp); ?>">Last</a>
            <?php } // Show if not last page ?></td>
      </tr>
  </table></td>
      </tr>
      <tr>
        <td><table width="219" border="0" cellpadding="0" bgcolor="#FFFFFF">
        <tr>
          <td width="63">&nbsp;</td>
          <td width="41"><a href="news_insert.php">Edit</a></td>
          <td width="84"><a href="../index.php" target="_blank">View  Update</a></td>
        </tr>
    </table></td>
        </tr>
      <?php } while ($row_NewsDisp = mysql_fetch_assoc($NewsDisp)); ?>
  </table></td>
<td valign="top"><span class="newstitle"><img src="../images/reader1.jpg" alt="Spirit Of A Champion" width="200" height="233" class="PicBoder_white" /></span></td>
   
   


<?php mysql_free_result($NewsDisp); ?> [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service