Boerboel649 Posted March 25, 2007 Share Posted March 25, 2007 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! Quote Link to comment Share on other sites More sharing options...
edawg Posted March 25, 2007 Share Posted March 25, 2007 \n Quote Link to comment Share on other sites More sharing options...
Boerboel649 Posted March 25, 2007 Author Share Posted March 25, 2007 \n As you can see in my code, I tried that but it's not working! Quote Link to comment Share on other sites More sharing options...
podja Posted March 25, 2007 Share Posted March 25, 2007 Isnt it possible to use <br /> ? Quote Link to comment Share on other sites More sharing options...
Waldir Posted March 25, 2007 Share Posted March 25, 2007 \n would put it on a different line but wont show on your html try echo nl2br($fullname); echo nl2br($number); echo nl2br($position); maybe? Quote Link to comment Share on other sites More sharing options...
Boerboel649 Posted March 25, 2007 Author Share Posted March 25, 2007 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"); } ?> Quote Link to comment Share on other sites More sharing options...
Waldir Posted March 25, 2007 Share Posted March 25, 2007 looks good Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.