form value from variable

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
skule
Forum Newbie
Posts: 3
Joined: Wed Oct 14, 2009 1:23 am

form value from variable

Post by skule »

When I want to enter a text string in a text box from a variable (i.e. $name) only the first word in the text string appear. That happend when the http form syntax is applied inside a PHP tag. It does NOT happend when the form syntax is applied outside a PHP tag. This should not happend, should it?

The application I have fetched a mysql record with a number of text string variables and show it in a form with a table in text tags for modifications. But only the first word in the strings appear. In text area nothing is shown.
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: form value from variable

Post by pbs »

Can you please post you text box code here.
skule
Forum Newbie
Posts: 3
Joined: Wed Oct 14, 2009 1:23 am

Re: form value from variable

Post by skule »

Example:
<?php
$a="this is a test";
echo '
<form name="form1" method="post" action="">
<label>a1
<input type="text" name="a1" id="a1" value='.$a.'>
</label>
</form>'; ?>

In this case only 'this' appair in the text box
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: form value from variable

Post by pbs »

<input type="text" name="a1" id="a1" value="'.$a.'">


replace input box code by above code
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: form value from variable

Post by jackpf »

Dude, making duplicate accounts and asking the same question really doesn't make me want to help you..

I told you this in your other thread.
skule
Forum Newbie
Posts: 3
Joined: Wed Oct 14, 2009 1:23 am

Re: form value from variable

Post by skule »

".$a" will only show .$a in the text box, and not the variable content.
You have to terminate the php echo string with a ' in order to display the $variable content. The " .." quotes will display the content between the marks as text string only.
Post Reply