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
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");   

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.