PHP help needed i haev a serious problem

Discussion in 'PHP' started by spark555, Jul 25, 2010.

  1. #1
    I am fetching record from the mysql table into textbox for editing purpose.

    but when i fetch into text box if content of the table is "ABC XYZ" then its displaying only xyz in the text box i am fetching usign this code

    $query="select * from table where id=1";
    $res=mysql_query($res);
    echo "<form method=post action=testdata.php name=frmedit>";
    while($myar=mysql_fetch_array($res))
    {
    echo "<input type=text name=txtname value=".$myar['name'].">";
    }
    echo "</form>";

    please help
     
    spark555, Jul 25, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Not sure if this is the problem without seeing a full text example, but you could add it anyway.

    
    echo "<input type=text name=txtname value=\"" . htmlentities($myar['name']); >";
    
    PHP:
     
    MyVodaFone, Jul 25, 2010 IP
  3. strgraphics

    strgraphics Active Member

    Messages:
    710
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    But according to your code..,
    
    $query="select * from table where id=1";
    
    PHP:
    this will fetch only one record......!!
     
    strgraphics, Jul 26, 2010 IP
  4. naveennadella

    naveennadella Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    echo "<input type=text name=txtname value='".$myar['name']."'>";

    Try addind single qoute like above
     
    naveennadella, Jul 27, 2010 IP
  5. Thorlax402

    Thorlax402 Member

    Messages:
    194
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    40
    #5
    That could very well be the problem. Without quotes it might be cutting off the content at the first space. I'm surprised you didn't get any errors with your current code though.
     
    Thorlax402, Jul 29, 2010 IP
  6. ThomasTwen

    ThomasTwen Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    try echoing $myar['name'] without anything around it and see what happens.
     
    ThomasTwen, Jul 29, 2010 IP