Jump to content

Converting guestbook entry newlines to html <br /> tags


tommybfisher

Recommended Posts

I have created a php guestbook for my site. The only problem I have with it is that when a user puts a carriage return in their entry, it is not replicated in the viewed post. I'm trying to figure out how I turn these returns into <br /> tags for display.

Do I do something with the php that handles the input (i.e. somehow replace carriage returns with <br />'s) or is it to do with the output php code?

Any pointers would be gratefully appreciated.

 

This is the php for the guestbook entries output:

<?php 
include "connection.php";
$table = "guestbook";
$data = mysql_query("SELECT * FROM $table ORDER BY id DESC") or die(mysql_error());

echo "<div class='divide_message'>";
while($info = mysql_fetch_array( $data ))
{ 
	$date = date("d/m/y",strtotime($info['date']));
	echo "<div class='block message'>"; 
	echo "<div class='message_name'>" . $info['name'] . "";
	echo "<span class='date'>" . $date . "</span></div><br />";
	echo "<div class='message_message'>" . $info['message'] . "</div>";
	echo "</div>";
} 
echo "</div>";
?> 

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.