SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    displaying data from a database with spaces in it.

    I have this data, I'm trying to display one in an input box, and the other in a text box for editing. Problem is, the input box one only displays the first word of the data, so if I put in a two word Product_Name, it only displays the first, whereas the text box does just what I want it to. It displays all the text, spaces or no spaces. I'm trying to figure out why that is.

    the two columns are set up like so, and its the Product_Name I'm having problems with, the URL one works perfectly fine, and I checked the database itself, it is storing the Product_Name correctly, spaces and all. I just can't get it to display properly.
    PHP Code:
    Product_Name       VARCHAR(60), 
    URL     VARCHAR(255), 
    I have noticed, if I change this input box
    PHP Code:
    <input type='text' name='product' size='50' maxlength='255' value=$editrow[Product_Name]> 
    to a text box
    PHP Code:
    <textarea name='text' COLS='50' ROWS='1' wrap>$editrow[Product_Name]</textarea
    it displays fine. Any suggestions?

  2. #2
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed this
    PHP Code:
    <input type='text' name='product' size='50' maxlength='255' value=$editrow[Product_Name]> 
    to this
    PHP Code:
    <input type='text' name='product' size='50' maxlength='255' value=`$editrow[Product_Name]`> 
    and it works fine

  3. #3
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Grand Rapids, MI
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If your ever not sure whats wrong, just take a look at the HTML source and it should be pretty clear. Its hard sometimes to see how everything looks once the variables are parsed.

  4. #4
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the input, but I'm not sure how that would have helped in this situation. The value of the input in view source had the space, but it wasnt being displayed in the input box. I knew that the value was correct already, and I knew it was an input box thing, I just didnt know how to fix it. Unless I'm missing something??

  5. #5
    Put your best practices away. The New Guy's Avatar
    Join Date
    Sep 2002
    Location
    Canada
    Posts
    2,087
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Could be something with the browser your using. Anyway use double quotes not single, wont change anything but its the standard.
    "A nerd who gets contacts
    and a trendy hair cut is still a nerd"

    - Stephen Colbert on Apple Users

  6. #6
    Put your best practices away. The New Guy's Avatar
    Join Date
    Sep 2002
    Location
    Canada
    Posts
    2,087
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Haha I cannot believed I missed that...Yah think about it, how does html tags determine where the attributes are? using spaces. Thus if you did value=$something and there is a space in $something it will turn out to be something like vlaue = something something2, where the browser will interprete something2 as a new attribute. So yah... use quotes
    "A nerd who gets contacts
    and a trendy hair cut is still a nerd"

    - Stephen Colbert on Apple Users


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
  •