php/mysql insert CR before dd/mm/yyyy in string
Posted: Mon Jul 02, 2012 12:12 pm
Hi everyone.
I'm wondering if anyone could suggest a solution to a problem i'm having. In a mysql db, i have a longtext datatype field with data such as:
"07/15/2008 this is a test 07/14/2008 this is a second test"
When I display the data on a page using the coding below, the text appears in a single line. I need a line break to occur before each date within the History field. Is this possible? Any help would be appreciated. Thanks.
I'm wondering if anyone could suggest a solution to a problem i'm having. In a mysql db, i have a longtext datatype field with data such as:
"07/15/2008 this is a test 07/14/2008 this is a second test"
When I display the data on a page using the coding below, the text appears in a single line. I need a line break to occur before each date within the History field. Is this possible? Any help would be appreciated. Thanks.
Code: Select all
<?php
$ID = $_GET['ID'];
$result = mysql_query("SELECT ID, History FROM HistoryTable WHERE ID='$ID'") or die(mysql_error());
echo "<table border='0' cellpadding='1'>";
echo "<tr>";
while($row = mysql_fetch_array( $result )) {
echo "<tr>";
echo '<td>' . nl2br($row['History']) . '</td>';
echo "</tr>";
}
echo "</table>";
?>