how to use <br> tag

Discussion in 'PHP' started by kharearch, Mar 11, 2008.

  1. #1
    I want to use <br> tag to show part of data into next line. but unable to do it. can somebody help me to format data.

    My code is following -

    <body>
    <?php
    $con = mysql_connect("localhost","dwarkapr_archana","reset123");

    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("dwarkapr_property",$con);

    $m = $_POST['mode'];
    echo $m;
    if($m == "buy")
    {
    $sql="select * from dwarka_property where mode = 'buy'";
    }
    else
    {
    if($m == "rent")
    {
    $sql ="select * from dwarka_property where mode = 'rent'";
    }
    else
    {
    if($m=="pg")
    {
    $sql="select * from dwarka_property where mode = 'pg'";
    }
    }
    }
    //echo $sql;
    $result = mysql_query($sql);



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

    echo $row['mode']." ";
    echo $row['type']." ";
    echo $row['city']." ";
    echo $row['budget']." ";
    echo $row['bedroom']." ";
    echo $row['properties_from'];
    <br>
    }mysql_close($con);

    ?>

    </body>
     
    kharearch, Mar 11, 2008 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    just put echo "<br>"; Would get better results using a table though.
     
    shallowink, Mar 11, 2008 IP
  3. Gonzo4u

    Gonzo4u Well-Known Member

    Messages:
    410
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Just add <br> if you are using HTML or <br /> if you are using XHTML at the end of your code like this:

    while($row = mysql_fetch_array($result))
    {
    echo $row['mode']." ";
    echo $row['type']." ";
    echo $row['city']." ";
    echo $row['budget']." ";
    echo $row['bedroom']." ";
    echo $row['properties_from']."<br />";
    }mysql_close($con);


    Regards,
    Gonzo
     
    Gonzo4u, Mar 11, 2008 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    just echo "<br>";
     
    Kaizoku, Mar 11, 2008 IP
  5. jaysa

    jaysa Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    u can do it by typing like this

    echo '<br />'; in the line where u wrote <br > tag
     
    jaysa, Mar 11, 2008 IP
  6. Namuk

    Namuk Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    try like this....

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

    echo "$row[mode].</br>";
    echo "$row[type].</br>";
    echo "$row[city].</br>";
    echo "$row[budget].</br>";
    echo "$row[bedroom].</br>";
    echo "$row[properties_from].</br>";

    }mysql_close($con);
     
    Namuk, Mar 11, 2008 IP
  7. dotWdot

    dotWdot Peon

    Messages:
    685
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    if you have a string using \n or \r then you can use echo nl2br($string);

    I know thats not your direct question, just adding it for reference ;D


    also you can just do one long string like:

    echo $str1."<br/>".$str2."<br/>".$str3;

    adding as many as you need too?
     
    dotWdot, Mar 11, 2008 IP