473,327 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Retrieving data from database and displaying in textbox/text area

vikas1111
122 100+
Hi All


Can anyone give me an idea to solve the problem.. My Problem is ,, I want to Retrieving data from database and displaying in textbox... If anybody have link of some good tutorial on this pls let me know..Or if anybody can explain I would be very thankful...
May 29 '08 #1
10 34820
coolsti
310 100+
You are asking a very general basic question, and I believe this forum tries to help with more specific problems. But to get you started, let us assume you wish to use PHP on the server side to interact with your database and then produce HTML output to send to the user's browser. And the database values are to be shown in the forms in the page that the HTML produces in the user's browser.

So you need to know how to invoke a PHP script on the server, how to get the PHP script to connect to your database, how to do a "select" query to get the data you want out of the database table or tables, how to then put those values into PHP variables which then can be outputted in the HTML that will produce the page. So you also need to know how to produce the HTML with the forms that you want, and how to place the PHP variables that came from the database into the forms in the proper place rather than just "hard coding" static variables there.

Just take the above one at a time and look at some documentations for PHP, SQL, HTML, etc.
May 29 '08 #2
vikas1111
122 100+
Thanks coolsti

How to place the PHP variables that come from the database into the forms in the proper place .i.e. in txt box or txt area...


I just want to know obout the above line....Other things i know..
May 29 '08 #3
rpnew
188 100+
Hi All


Can anyone give me an idea to solve the problem.. My Problem is ,, I want to Retrieving data from database and displaying in textbox... If anybody have link of some good tutorial on this pls let me know..Or if anybody can explain I would be very thankful...
Hi,
I've seen your last post regarding inserting data problem so i guess you know how to use PHP to get data.. and put it them into variable. So you can simple do the following to display it in the text box...
1.
[PHP]
<?php
//your php code for fetching data and geting them into variable
?>

<input type="text" name="xyz" value=<?php echo $val; ?> >
[/PHP]
or
2.
[PHP]
<?php
//your php code for fetching data and geting them into variable

echo "<input type=\"text\" name=\"xyz\" value='$val'>";
[/PHP]

You can use either of the way... just be careful with escaping " in second example..

This is not related to your problem exactly but you may find this
thread useful for comparision for above two ways
May 29 '08 #4
vikas1111
122 100+
Hi,
I've seen your last post regarding inserting data problem so i guess you know how to use PHP to get data.. and put it them into variable. So you can simple do the following to display it in the text box...
1.
[PHP]
<?php
//your php code for fetching data and geting them into variable
?>

<input type="text" name="xyz" value=<?php echo $val; ?> >
[/PHP]
or
2.
[PHP]
<?php
//your php code for fetching data and geting them into variable

echo "<input type=\"text\" name=\"xyz\" value='$val'>";
[/PHP]

You can use either of the way... just be careful with escaping " in second example..

This is not related to your problem exactly but you may find this
thread useful for comparision for above two ways

Thanks

I am trying tp do in this way but its not working..


[PHP]
while($row = mysql_fetch_array($result))
{
echo "<input type="text" name="txtname" value='$row['id']'>";
}
[/PHP]


Connection and mysql syntax are correct..Only problem in displaying in textbox..

I am getting proper output to the bellow code...
[PHP]

while($row = mysql_fetch_array($result))
{
echo "<td>" . $row['id'] . "</td>";
}

[/PHP]
May 29 '08 #5
rpnew
188 100+
Thanks

I am trying tp do in this way but its not working..


[PHP]
while($row = mysql_fetch_array($result))
{
echo "<input type="text" name="txtname" value='$row['id']'>";
}
[/PHP]


Connection and mysql syntax are correct..Only problem in displaying in textbox..

I am getting proper output to the bellow code...
[PHP]

while($row = mysql_fetch_array($result))
{
echo "<td>" . $row['id'] . "</td>";
}

[/PHP]
First tell me what are you geting as output...

second thing i guess you need to escape your ' into your example like this... try this..
[PHP]
echo "<input type="text" name="txtname" value='$row[\'id\']'>";

[/PHP]

Regards,
RP
May 29 '08 #6
vikas1111
122 100+
I have created a table in mysql database to insert some records say students or employee records.. Now what i have to do is i have to display all the records in admin view page..( which i have done).. There is an option provided for editing the records beside every record.. So when the admin clicks on the edit button another form should open which will contain information of the user in the text box so that he can just edit and save the changes back into the databse..

This is a part of what i have coded..

[PHP]
include("connection.php");
$result = mysql_query("SELECT * FROM usttable");
while($row = mysql_fetch_array($result))
{
echo "<input type="text" name="txtname" value='$row[\'id\']'>";
}

[/PHP]
May 29 '08 #7
rpnew
188 100+
I have created a table in mysql database to insert some records say students or employee records.. Now what i have to do is i have to display all the records in admin view page..( which i have done).. There is an option provided for editing the records beside every record.. So when the admin clicks on the edit button another form should open which will contain information of the user in the text box so that he can just edit and save the changes back into the databse..

This is a part of what i have coded..

[PHP]
include("connection.php");
$result = mysql_query("SELECT * FROM usttable");
while($row = mysql_fetch_array($result))
{
echo "<input type="text" name="txtname" value='$row[\'id\']'>";
}

[/PHP]
Hi,
can you be a little more specific.. i guess i'm a bit confused with what you exactly want... i mean are you getting any error or you are asking how do i do that?

Regards,
RP
May 29 '08 #8
vikas1111
122 100+
<input type="text" name="text1" value="<?php echo $row["usr_password"]; ?>">

This line I was searching for .....


THANKS
May 29 '08 #9
rpnew
188 100+
<input type="text" name="text1" value="<?php echo $row["usr_password"]; ?>">

This line I was searching for .....


THANKS
welcome,
Glad that you found solution.
come back whenever you have problem.

Regards,
RP
May 29 '08 #10
vikas1111
122 100+
welcome,
Glad that you found solution.
come back whenever you have problem.

Regards,
RP

Sure RP Thanks once again..
May 29 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Danny F | last post by:
Is it possible to have line feeds/breaks automatically entered when the text wraps to a new line? I am using a <textarea> input on a form and using the <pre> tag when displaying the text to a html...
3
by: Targa | last post by:
How can I clear a text field by clicking on a button? Ive searched the web and found tons of scripts that will clear text just entered but I am displaying results from a database into a text area...
2
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different...
5
by: aniket_sp | last post by:
i am using a data adapter and a dataset for filling and retrieving data into .mdb database. following is the code..... for the form load event Dim dc(0) As DataColumn Try If...
1
by: si_owen | last post by:
is it possible to add a data control to a text area???
11
by: pardesiya | last post by:
Friends, I am having trouble displaying Japanese text within a textbox (or anywhere else) in an aspx page with .net 2.0 framework. Initial default text in Japanese displays perfectly but when I...
1
by: seadog | last post by:
Hi, I am having a problem displaying data in a textbox array. What I am trying to do is have 5 number enter 5 textboxes, starting from the first and working there way to the bottom textbox. What...
4
by: devnewbie | last post by:
Hi, I was wondering if someone would be so kind to point me in the right direction. I would like to retrieve address from a database (could be as simple as a excel spreadsheet) and display them on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.