Jump to content

[SOLVED] Problem with HTML Form


bzptlx

Recommended Posts

I'm new here and if this has been asked and solved before I am sorry for the dupe. I am using PHP 5.2.4 with Apache 2 and MySql 5.0.45.

 

I am having a problem displaying data in an HTML for for updates. The data is truncated at the first space in the form field.

 

        For instance "The Beer Store" is displayed as "The".

 

If I display the data outside the form field (input type-text) it displays correctly so I know the pull from the database is working correctly.

 

Any ideas? TIA

Link to comment
Share on other sites

Here is the code section. The one highlighted in green works properly but the one in red stops sidplay after the first space:

 

$query  = "SELECT * FROM location where idnum='1'";

$result = mysql_query($query);

 

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{

echo "<form>";

echo "<tr border=0>";

    echo "<td border=0>";

    echo "<div class=btxt>Name:&nbsp";

    echo "<input type=text size=50 value={$row['name']}>{$row['name']}</div>";

    echo "</td>";

echo "</tr>";

 

.......

Link to comment
Share on other sites

Put quotes around the value of every parameter.

 

   echo "<input type=text size=50 value={$row['name']}>{$row['name']}</div>";

 

Is going to evaluate to

 

<input type=text size=50 value=The Beer Store>The Beer Store</div>

 

The browser is going to interpret this as an input tag with the value attribute set to The and two additional unknown attributes Beer and Store.

 

Change all your tags so they look like this.

 

   echo "<input type=\"text\" size=\"50\" value=\"{$row['name']}\">{$row['name']}</div>";

 

This way value will be set to The Beer Store instead of The.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.