472,958 Members | 2,149 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

displaying data to form....

dba
Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the same
form. Have been doing googles and have for some time been displaying
using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.
Jun 2 '08 #1
11 2365
dba wrote:
Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the same
form. Have been doing googles and have for some time been displaying
using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.
You need alt.html to find out how html works.

Hint - the input field has a "value" attribute which contains the test
you wish to display in it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #2
On May 6, 7:44 pm, dba <some...@someplace.orgwrote:
Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the same
form. Have been doing googles and have for some time been displaying
using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.
Okay, I think I know what you are trying to do. You want to retrieve
data from a db to populate entry options on a form that was initially
used to enter the information. Here's sample code from one of my
scripts to give you a good example on how to do this. This is for the
select/options html element. You will have to do it differently for
text areas, radio boxes, and others. But this snippet should get you
on the right track:
//run the query to get all data stored in the INTAKE 1 FORM for this
id

$query = "select * from intake1 where consumer_id = ".$id;
$result = mysql_query($query);
if($row = mysql_fetch_array($result)) {

//there are many fields, but we are just using this one
//for demonstration purposes

$gender_form_entry = $row["gender_id"];
}
later on down the page i have this code for the gender section on the
form
<form>
....
<td>
<div class="formUnitVertical">
<label for="gender">Gender:</label>
<br/>
<select name="gender">
<?php

//get data entered in the gender table
$genderQuery = "select * from lst_gender";
$result = mysql_query($genderQuery);

//take resultset and makeform vars
while($row=mysql_fetch_array($result)) {

$gender_id = $row["id"];
$gender_type = $row["gender"];

//see if there is a gender id stored for
this form
//associated with this consumer id
if($gender_form_entry == $gender_id){

//yes, there is an id stored for this
form that matches
//an id from the gender table, so mark
it as SELECTED
echo "<option value=\"".$gender_id."\"
selected>".$gender_type."</option>";

}else{

//nothing stored in database, select
nothing
echo "<option value=\"".$gender_id."\">".
$gender_type."</option>";

}
}
?>
</select>
</div>
</td>
....
<input type='submit' />
...
</form>
hope this helps

chris
Jun 2 '08 #3
On May 7, 1:44 am, dba <some...@someplace.orgwrote:
Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the same
form. Have been doing googles and have for some time been displaying
using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.
<input type="text" name="inputFieldName" value="<?php echo
($thisFieldValue); ?>" />

If the data contains characters that have special meaning in HTML such
as < & etc then use htmlspecialchars () to escape them.

Textareas simply require you to do the echo between the <textareaand
</textareatag.

Now you know how to do inputs and textareas I'll leave selects,
checkboxes and radio buttons as an exercise for the original poster.
Hint: Select options have a "selected" attribute, checkboxes and
radios have a "checked" attribute.
Jun 2 '08 #4
dba
Really?

<input type="text" name="inputFieldName" value="<?php echo
($thisFieldValue); ?>" />

Jerry Stuckle wrote:
dba wrote:
>Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the same
form. Have been doing googles and have for some time been displaying
using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.

You need alt.html to find out how html works.

Hint - the input field has a "value" attribute which contains the test
you wish to display in it.
Jun 2 '08 #5
dba
Thanks so much Chrisv and Gordon. That jogged my memory. I appreciate
the help.

Gordon wrote:
On May 7, 1:44 am, dba <some...@someplace.orgwrote:
>Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the same
form. Have been doing googles and have for some time been displaying
using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.

<input type="text" name="inputFieldName" value="<?php echo
($thisFieldValue); ?>" />

If the data contains characters that have special meaning in HTML such
as < & etc then use htmlspecialchars () to escape them.

Textareas simply require you to do the echo between the <textareaand
</textareatag.

Now you know how to do inputs and textareas I'll leave selects,
checkboxes and radio buttons as an exercise for the original poster.
Hint: Select options have a "selected" attribute, checkboxes and
radios have a "checked" attribute.
Jun 2 '08 #6
dba
chrisv,

Jogged my memory and then a lot more. Thanks again.

chrisv wrote:
On May 6, 7:44 pm, dba <some...@someplace.orgwrote:
>Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the same
form. Have been doing googles and have for some time been displaying
using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.

Okay, I think I know what you are trying to do. You want to retrieve
data from a db to populate entry options on a form that was initially
used to enter the information. Here's sample code from one of my
scripts to give you a good example on how to do this. This is for the
select/options html element. You will have to do it differently for
text areas, radio boxes, and others. But this snippet should get you
on the right track:
//run the query to get all data stored in the INTAKE 1 FORM for this
id

$query = "select * from intake1 where consumer_id = ".$id;
$result = mysql_query($query);
if($row = mysql_fetch_array($result)) {

//there are many fields, but we are just using this one
//for demonstration purposes

$gender_form_entry = $row["gender_id"];
}
later on down the page i have this code for the gender section on the
form
<form>
...
<td>
<div class="formUnitVertical">
<label for="gender">Gender:</label>
<br/>
<select name="gender">
<?php

//get data entered in the gender table
$genderQuery = "select * from lst_gender";
$result = mysql_query($genderQuery);

//take resultset and makeform vars
while($row=mysql_fetch_array($result)) {

$gender_id = $row["id"];
$gender_type = $row["gender"];

//see if there is a gender id stored for
this form
//associated with this consumer id
if($gender_form_entry == $gender_id){

//yes, there is an id stored for this
form that matches
//an id from the gender table, so mark
it as SELECTED
echo "<option value=\"".$gender_id."\"
selected>".$gender_type."</option>";

}else{

//nothing stored in database, select
nothing
echo "<option value=\"".$gender_id."\">".
$gender_type."</option>";

}
}
?>
</select>
</div>
</td>
...
<input type='submit' />
..
</form>
hope this helps

chris

Jun 2 '08 #7
dba wrote:
Really?

<input type="text" name="inputFieldName" value="<?php echo
($thisFieldValue); ?>" />

Jerry Stuckle wrote:
>dba wrote:
>>Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12"
name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36"
name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the
same form. Have been doing googles and have for some time been
displaying using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.

You need alt.html to find out how html works.

Hint - the input field has a "value" attribute which contains the test
you wish to display in it.
Yes. "value" is an html attribute, not PHP code. Learn the difference.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #8
dba wrote:
Jerry Stuckle wrote:
>dba wrote:
>>Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12"
name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36"
name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the
same form. Have been doing googles and have for some time been
displaying using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.

You need alt.html to find out how html works.

Hint - the input field has a "value" attribute which contains the test
you wish to display in it.

Really?

<input type="text" name="inputFieldName" value="<?php echo
($thisFieldValue); ?>" />
Oh, and please don't top post. (Top posting fixed this time).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #9
dba
I understand retard. Perhaps you ought to find something else to do with
your time.

Also, we have gone over your "flat earth society" bottom post rant before.

NEVER
Jerry Stuckle wrote:
dba wrote:
>Really?

<input type="text" name="inputFieldName" value="<?php echo
($thisFieldValue); ?>" />

Jerry Stuckle wrote:
>>dba wrote:
Have been displaying data from database using html for some time but
just recently trying to display data back to "form". Can't find answer.

<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12"
name="Fname"><br >
Last Name:<input type="text" size="12" maxlength="36"
name="Lname"><br />
Gender:<br />
Male:<input type="radio" value="Male" name="gender"><br />
Female:<input type="radio" value="Female" name="gender"><br />

Now once I have the data in the database I want to display in the
same form. Have been doing googles and have for some time been
displaying using html like

echo "Hello, ".$Fname." ".$Lname.".<br />";
echo "You are ".$gender.", and you like ";

but just lately realized I have never display in a "form".

Any help will be appreciated.
You need alt.html to find out how html works.

Hint - the input field has a "value" attribute which contains the
test you wish to display in it.

Yes. "value" is an html attribute, not PHP code. Learn the difference.
Jun 2 '08 #10
On Wed, 07 May 2008 16:53:35 +0200, dba <so*****@someplace.orgwrote:
I understand retard. Perhaps you ought to find something else to do with
your time.
Hmmmz, after he helped you?
Also, we have gone over your "flat earth society" bottom post rant
before.
Ah, so you do know you should bottom post allready?
1 & 1 = PLONK

Have a very pleasant life.
--
Rik Wasmus
Jun 2 '08 #11
dba
Thanks for the thoughtful gesture. It is truly appreciated.

Rik Wasmus wrote:
On Wed, 07 May 2008 16:53:35 +0200, dba <so*****@someplace.orgwrote:
>I understand retard. Perhaps you ought to find something else to do
with your time.

Hmmmz, after he helped you?
>Also, we have gone over your "flat earth society" bottom post rant
before.

Ah, so you do know you should bottom post allready?
1 & 1 = PLONK

Have a very pleasant life.
Jun 2 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to...
5
by: Robert | last post by:
Hello Accessors I have some reports created in Access that are very good for what they do. However, it seems to me that when you are displaying information you don't need to print out that a...
9
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There...
5
by: Tomaz Koritnik | last post by:
Hi I have many short HTML files stored in a binary stream storage to display descriptions for various items in application. HTML would be display inside application using some .NET control or...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
4
by: MrL8Knight | last post by:
Hello, I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to...
2
by: MLH | last post by:
A97 Am having difficulty displaying graph in Form View that I see fine in graph control on form opened in design view. I know I'm doing something wrong. If I open the form in design view - I...
13
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or...
1
by: ColebyA | last post by:
Hi I am using ASP and HTML to process a form. The first form calls another page to process the data. When the page processes it redirects to a page confirming submission. I want to display the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.