Jump to content

Starting new line in text in PHP


Boerboel649

Recommended Posts

Hi all,

This should be a quick simple question.  How do you start new lines in text in PHP?  I thought I knew how but it's not working.  It just puts it all on one line.

 

Here's my code:

 

<?php
$_GET['id'];
$query = mysql_query("SELECT fname, lname, nickname, number, position, height, weight, other  FROM players WHERE id = '$id'");
while ($result = mysql_fetch_array($query)) {
$fname = $result['fname'];
$lname = $result['lname'];
$nickname1 = $result['nickname'];
$nickname2 = "\"$nickname1\"";
$number = $result['number'];
$position = $result['position'];
$height = $result['height'];
$weight = $result['weight'];
$other = $result ['other'];
$fullname = "$fname $nickname2 $lname";
echo "$fullname\n";
echo "$number\n";
echo "$position\n";
}
?>

 

I would think that the \n would do it, but it's not!

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/44261-starting-new-line-in-text-in-php/
Share on other sites

Thanks!  here's my final code to get that to work...

 

 

<?php

$_GET['id'];

$query = mysql_query("SELECT fname, lname, nickname, number, position, height, weight, other  FROM players WHERE id = '$id'");

while ($result = mysql_fetch_array($query)) {

$fname = $result['fname'];

$lname = $result['lname'];

$nickname1 = $result['nickname'];

$nickname2 = "\"$nickname1\"";

$number = $result['number'];

$position = $result['position'];

$height = $result['height'];

$weight = $result['weight'];

$other = $result ['other'];

$fullname = "$fname $nickname2 $lname";

echo nl2br("$fullname\n");

echo nl2br("$number\n");

echo nl2br("$position\n");   

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.