Jump to content

Linebreaking three echo variables


Recommended Posts

hi...how do i linebreak three echo variables so they are not in the same line?.. so it looks like this (instead of all on the same line):

Name: $membername
Age: $memberage
Gender: $membergender

I tried to do the following that was recommended to linebreak the variables into different lines..but it ended up being on the same line.
echo: "Name: $membername\n Age:$memberage\n Gender: $membergender";

Here is the code below...Thanks in advance:
===============


<?php

            $info = mysql_query("SELECT * FROM `info` WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
            $info1 = mysql_fetch_assoc($info;
            $membername = $info1['membername'];
            $memberage = $info1['memberage'];
            $membergender = $info1['membergender'];

           echo "Name: $membername";
           echo "Age: $memberage";
           echo "Gender: $membergender";
           
      
            
     ?>

Edited by learningphpisfun
Link to comment
Share on other sites

I think instead of \n its \r\n. You could always print them inside <pre> tags, or use var_dump(), which will print the information + a little more on separate lines. 

 

edit. or simply use <br /> tags

Edited by insidus
Link to comment
Share on other sites

@insidius...thanks for the response... I tried to embed html within php and it didn't work cause I placed the </br>  outside  the echo quotes..... Your response made me think there was a way to embed html within php...and I did some googling and found out that I have to put the </br> inside the quote and not outside...

 

I know it seems noobish but the php tutorial that I was following just showed how to make a basic registration form that echos "welcome $User" when you successfully log in.. It didn't cover embedding html within php or anything... The only time the tutorial used html was to create the form and that was outside <?php ?>..so i didn't have any examples of embedding html within php to use as a guide...anyways a million thanks for responding with a productive and useful solution.

Edited by learningphpisfun
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.