Modify the code to convert newline characters in each entry into HTML br tags

PLease help me to change the code?

:’(

[php]

<?php $dbc = mysql_connect('localhost', 'username', 'password'); mysql_select_db('myblog', $dbc); $query = 'SELECT * FROM entries ORDER BY date_entered DESC'; if ($r = mysql_query($query, $dbc)) { while ($row = mysql_fetch_array($r)) { print"

{$row['title']}

{$row['entry']}
Edit Delete
\n"; } } else { print '

Could not retrieve data because:
' . mysql_error($dbc) . '.

The query being run was: ' .$query . '

'; } mysql_close($dbc); ?>

[/php]

Hi zhen,

Try changing:

[php]{$row[‘entry’]}
[/php]

To:

[php]{$row[‘entry’]}[/php]

And:

[php]<a href=“edit_entry.php?id={$row[‘entry_id’]}”>Edit
<a href=“delete_entry.php?id={$row[‘entry_id’]}”>[/php]

To:

[php]<a href=“edit_entry.php?id={$row[‘entry_id’]}”>Edit


<a href=“delete_entry.php?id={$row[‘entry_id’]}”>[/php]

Hope this helps…

William

If I understand correctly, change this line:

[php]
{$row[‘entry’]}

[/php]

To:

[php]
" . nl2br($row[‘entry’]) . "
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service