Displaying database entries in an input text box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
K-Z
Forum Commoner
Posts: 29
Joined: Mon Jul 05, 2010 9:03 am

Displaying database entries in an input text box

Post by K-Z »

Hi...I want to know that is it possible to display that data that is stored in the database in a textbox with the help of javascript. I am able to do this with php but the problem is mis-location of the text or data in the textbox. I want to show the data in the text box from the first position. The php code I am using is:

Code: Select all

// suppose I want to show the data stored in '$y' variable in the text box
<textarea name="name" id="2" cols="23" rows="10">
<?php echo "$y"; ?> </textarea>
Is there anything wrong in the php code or mis-location of text can only be prevented using ajax or javascript. If yes, please tell me the solution.
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: Displaying database entries in an input text box

Post by Gargoyle »

don't put $y into quotes.

other than that, you can't (directly) access a database through javascript.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Displaying database entries in an input text box

Post by VladSun »

Rewrite your code (HTML+PHP) in a single line ;)
There are 10 types of people in this world, those who understand binary and those who don't
K-Z
Forum Commoner
Posts: 29
Joined: Mon Jul 05, 2010 9:03 am

Re: Displaying database entries in an input text box

Post by K-Z »

Thank you everyone....I have solved my problem...
Post Reply