SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Bickerstaffe
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Text area and PHP

    I have a problem. I have a form which allows data to be retrieved from mysql database and displayed in the form which can then be updated. updated.

    <tr>
    <td width="315" height="26" class="borders">
    Details
    </td>
    <td width="300" height="26" class="borders">
    <textarea name="details" rows=10 cols=40> <?php echo $details ?> </textarea>
    </td>
    </tr>

    When the submit button is selected a program runs to update the database

    $query = "UPDATE cd_cust SET area='$area', price='$price', type='$type', details='$details', address='$address', imagedest='$imagedest' WHERE postcode='$postcode'";

    However next time I view the record the text displays one place to the right.
    Each time the record is displayed it moves over another position.


  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    Hi Janet,
    Do you mean it adds a space each time the form is submitted?
    if so, take out the spaces before and after the echo...
    PHP Code:
    <textarea name="details" rows=10 cols=40><?php echo $details?></textarea>
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Bickerstaffe
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Spikez

    What is happening is.

    If I type the following into the form

    Do not move this text

    The next time I display the form it has moved over one space

    Do not move this text

    and everytime I review it it moves over another. Therefore after 5 updates the text on the form looks like this:
    Do not move this text

    I am not sure what you mean when you say remove the space before and after the echo. Do you mean the following:

    <textarea name="details" rows=10 cols=40> <?php echo$details?> </textarea>

    I tried that but it made no difference.

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    spike told u that u misse the semicollon after $details....
    like $details;
    cheers

  5. #5
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Bickerstaffe
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thankyou

    I now understand.

    Oh to have a brain!

    Cheers

  6. #6
    SitePoint Addict Chillijam's Avatar
    Join Date
    Nov 2003
    Location
    England
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What Spikez was saying was that you need to remove the spaces from the HTML code in your textarea tag.

    Instead of

    Code:
    <textarea name="details" rows=10 cols=40> <?php echo $details; ?> </textarea>
    You need

    Code:
    <textarea name="details" rows=10 cols=40><?php echo $details; ?></textarea>
    Otherwise your post data will contain the following text for the value of $details = "Hello world!" (spaces replaced with _)

    Code:
    _Hello_World!_
    Your mind is like a parachute. It works best when open.
    (HH The Dalai Lama)

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    Thanks Guys, sorry Janet I didn't make it clear what I meant!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

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