how to make it appear in mulit line like as in database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dhivya
    New Member
    • Jul 2012
    • 1

    how to make it appear in mulit line like as in database

    I used

    Code:
    <textarea name="question" class="input" width="250"></textarea>
    to add data in sql. i used multi line , in database also data is stored in multi line only.

    Then i used
    Code:
    $question=$row['1'];
    echo "<tr><td colspan='5'>",$row[1],"</td></tr>
    to display the data but the data is displaying in single line.

    How do I make it appear in multiple lines like as in database?
    Last edited by Frinavale; Jul 27 '12, 02:13 PM. Reason: Added code tags.
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    #2
    well for one thing you need to use periods . instead of comma , to concatenate your string like this:

    wrong way
    echo "<tr><td colspan='5'>",$row['1'],"</td></tr>";

    right way
    echo "<tr><td colspan='5'>".$row['1']."</td></tr>";

    also how much text are you displaying. Here you are spanning 5 columns. Is the text you are streaming out longer than the width of the 5 columns?

    Comment

    • computerfox
      Contributor
      • Mar 2010
      • 276

      #3
      Are you trying to print out all the data returned by mysql?

      What I normall do is:

      Code:
      <?php
        $getter=mysql_query();  //Query to grab all needed data
        while($info=mysql_fetch_assoc($getter)){
               //Print data
               //At this point, you can break the php and just use regular HTML
              //Note: when you want to print the data, you have to re-enter PHP
             //Note: you never HAVE to stay in pure PHP
       }
      
      ?>

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        wrong way
        echo "<tr><td colspan='5'>",$ row['1'],"</td></tr>";
        that’s actually a right way, works as well as concatenation.


        //Note: you never HAVE to stay in pure PHP
        but you should. breaking in and out of one language is bound to create confusion very very fast.

        Comment

        • Murat Bastas
          New Member
          • Jul 2012
          • 25

          #5
          wrong way
          echo "<tr><td colspan='5'>",$ row['1'],"</td></tr>";
          Claus Mygind why wrong this way?

          This is true in fact the use of...

          Comment

          • Claus Mygind
            Contributor
            • Mar 2008
            • 571

            #6
            Murat Bastas - Then what is the correct answer to dhivya question?

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              Although I’m not Murat Bastas, I hazard a guess at nl2br().

              Comment

              • Murat Bastas
                New Member
                • Jul 2012
                • 25

                #8
                Php - Wordwrap() function , You need this.

                Claus Mygind, my answer to that right?

                Comment

                • Murat Bastas
                  New Member
                  • Jul 2012
                  • 25

                  #9
                  nl2br function will work.

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    well, it seems like the line breaks are already there, they just don’t behave like they are assumed to do (because they follow the specification).

                    @Murat: you don’t need to quote me every time.

                    Comment

                    Working...