Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Newline chars not producing a New Line

Status
Not open for further replies.

miikel

ISP
Jul 28, 2004
21
GB
I am trying to get PHP to output a new line char to the screen, but the text stubbornly stays on one line.
I have tried using \n in various places, but do not get the desired results - either division by 0 error, Session-Start : Cannot output header, \n in the string or no new line!
I have also tried combinations of print (chr(10)); and print(chr(13)); but this just does nothing at all to the output text.
This is prolly an obvious one, but I have not been coding PHP for very long (about a week!) and could do with some help, please.

<DIV class ="myText" id="myText">
<STRONG>
<?php
print ($db_info['Title']); //NEW LINE WANTED HERE
?></STRONG>
<?php

print ($db_info['School']);

?>

</DIV>

 
Hi,
Try this:
Code:
  <DIV class ="myText" id="myText">
    <STRONG>
    <?php
    print ($db_info['Title']) . "<br>";    //NEW LINE WANTED HERE
    ?></STRONG>
    <?php

    print ($db_info['School']) . "<br>";
    
    ?>

[cheers]
Cheers!
Laura
 
Thank you Laura for the reply.
This had occured to me, and it does the job - but...
The line space it puts in seems to be a double line space
- perhaps not double, but too much space anyways. I just want to have a new line.
But thanks again for taking the time to reply.
 
For the record, I am using your (Laura) solution, and I've got round the spacing issue by altering the line-height property in the style sheet for this element.

Thanks.
 
miikel
You need to consider the medium you are using: HTML. The HyperText Markup Language is not whitespace specific, i.e. newlines have absolutely no meaning as they are considered formatting elements for the source, not for the rendered page. Same for multiple spaces, tabs, carriage returns.
Using CSS to format appearance is a good idea and the best way to control the layout. Tables - although frowned upon - are still a valid alternative.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top