Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2005
    Location
    Louisville, KY
    Posts
    61

    News System(Problem Viewing News)

    Okay so i created a news system, were i can psot news on my site and others can view it, but there is a problem. I will give you an example first.

    Form Box (Begining)

    Welcome to the site.

    Enjoy your stay!

    Form Box (End)

    So I post that and it inserts it into my Mysql database. But, when i go to view it on my site it will show up like this.

    News Show (Begin)

    Welcome to the site. Enjoy your stay!

    News Show (End)

    Why did it not put in the line space, it just puts them together. So i go check my mysql table and in the table it inserted the space. But, when it come out on the site there is no space. Why?

    If this helps to show the news i use this code.


    Code:
    <?php
    
    include "db.php";
    
    $query="SELECT * FROM site_news ORDER BY id DESC LIMIT 8";
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    $i=0;
    while ($i < $num) {
    
    $title=mysql_result($result,$i,"title");
    $date=mysql_result($result,$i,"date");
    $image=mysql_result($result,$i,"image");
    $text=mysql_result($result,$i,"text");
    $name=mysql_result($result,$i,"name");
    
    //I changed below just to give you an idea, it is really a bunch over tables to give the right look
    echo $title;
    echo "<br>"
    echo $text;
    
    $i++;
    }
    
    ?>

    Help Please!!

  2. #2
    It sounds like you need to enter the text into the form box as html. Separate lines with a <br> and it should display correctly.

  3. #3
    Join Date
    Feb 2005
    Location
    Louisville, KY
    Posts
    61
    I dont not understand???

  4. #4
    When you do the 'echo $text', the browser is interpreting it as html. Since there is no <br> in the contents of the $text variable, it's displaying it all on one line.

    When you type the data into your form, it needs to look like this:

    Welcome to the site.<br>
    Enjoy your stay!

  5. #5
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    You need to do this.

    echo nl2br($text)
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •