New Line IN php

Avatar
  • Answered
when i retrieve information in php page from database it display every thing in one line but I want break in lines?
Avatar
Scott
Hello, When you retrieve data from a database, you will want to ensure you format it before printing it out on the screen. Looking at the linked article, check out the second code section in step 2, particularly the piece below. It is a sample of how to format your data. As it is 'echoing the data to the screen in HTML, it simply uses a <br /> tag to create a line break.
while($row = mysql_fetch_array($comments, MYSQL_ASSOC)) { $name = $row['name']; $email = $row['email']; $website = $row['website']; $comment = $row['comment']; $timestamp = $row['timestamp']; $name = htmlspecialchars($row['name'],ENT_QUOTES); $email = htmlspecialchars($row['email'],ENT_QUOTES); $website = htmlspecialchars($row['website'],ENT_QUOTES); $comment = htmlspecialchars($row['comment'],ENT_QUOTES); echo "
Name: $name
Email: $email
Website: $website
Comment: $comment
Timestamp: $timestamp
";
Kindest Regards, Scott M