php - Mysql Query formatting issue -



php - Mysql Query formatting issue -

i'm building private message system, , database has multiple lines. in database:

i love song you? -joe

but query ends displaying this

i love song you? -joe

here's query

<?php include 'core/init.php'; protect_page(); include 'includes/overall/header.php'; $username = $user_data['username']; ?> <?php $result = mysql_query("select * messages sentto1='$username'"); echo '<h2>messages: </h2><br>'; while($row = mysql_fetch_array($result)){ echo '<b>from: '; echo $row['from1']; echo '</b><br><br>'; echo 'subject: '; echo $row['subject1']; echo '<br><br>'; echo 'message: '; echo $row['message1']; echo "<br />"; echo "<br />"; } ?> <?php include 'includes/overall/footer.php'; ?>

thanks in advance.

use nl2br(), replace newline characters html <br> tags.

echo nl2br($row['message1'], false);

php mysql database formatting

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -