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>";
?> 

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.