Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    In need of serious help(php and text areas)

    Hello,

    im currently designing a website where the user, once registered can post his or her news on the front page. To accomplish this i made a text area where it will store the string in a php variable named $news once the user hit submits. Heres my problem.

    For testing purposes i just hit the letter T until two rows of t's are made in the text area. The problem is, on the table where i display the message(which is the same size as the textarea) it only dispalys one row(it will combine the two rows of T's by readjusting the table.

    So basically what i want to have happen is the structure the user has in the text area should be maintained when it is displayed simular to how these forums work.
    ---------------------------------
    1.Evaluating the text area and textboxes

    $nt=$_POST['newstopic'];
    $ng=$_POST['newsgame'];
    $nm=$_POST['newsmessage'];
    $nd=date("l F dS Y h:i a");
    $na=$_SESSION['userwhoposted'];
    mysql_query("INSERT INTO newstories (topic,message,author,date,gametype) VALUES ('$nt','$nm','$na','$nd','$ng')");
    echo"<font color=\"white\">News sucessfully updated<br></font><br>";

    -----------------------------------
    2.Display code
    $query = "SELECT * FROM newstories order by id DESC LIMIT 10";
    $result = mysql_query($query,$db);
    echo "<TABLE style=\"table-layout:fixed\" style=\"color:white\" border=\"0\" cellspacing=\"0\" width=\"100%\">";
    while($r=mysql_fetch_array($result))
    {
    echo "<TR>";
    echo"<TD width=\"100%\">";
    echo "<table style=\"color: white\" border=\"1\" bordercolor=\"#00ffff\" cellspacing=\"0\" width=\"100%\">";
    echo"<tr>";
    echo"<td BGCOLOR=\"#0096B8\" ><font color=white>Subject:</font></td>";
    echo"<td BGCOLOR=\"#0096B8\" background=\"/images/blgr016.jpg\">";
    echo"<b>$r[topic]</b>";
    echo"</td>";
    echo"</tr>";
    echo"<tr>";
    echo"<td width=\"30%\"valign=top>$r[author]<br>";
    echo"</td>";
    echo"<td>";
    $stringb=$r['message'];
    echo"$stringb";
    echo"<br>Submitted:".$r['date']."</td></tr></table>";
    echo"</td></tr>";//end of one news item
    }
    -----------------------------------------
    Last edited by juniorx; 05-02-2004 at 02:37 PM.

  • #2
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    It helps if you display the actual code

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    done. Message is the part im having trouble with.

  • #4
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    ok...

    In your example of a long string of t's being entered, there is no new line character being entered; combine that with the use of percentages for your table column attributes means it will not display on two lines.

    There are several ways to solve that problem:

    - fix the width of the table cell
    - add new line characters to the message at certain points
    prior to saving to the database
    - add new line characters to the message at certain points
    just prior to displaying

    I am sure you get the drift

    Lite...

  • #5
    New Coder
    Join Date
    May 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    k how do i make it such that once they reach the end of the textbox on each row, that if their in the middle of a word, it will take that word and automatically insert a carriage return and move that word to the next line
    Last edited by juniorx; 05-02-2004 at 03:27 PM.

  • #6
    New Coder
    Join Date
    May 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nm seems to be working now.


  •  

    Posting Permissions

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