By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

Please help..

P: n/a
If someone can either direct me to some howto or even provide me with
an example, I would be grateful.

I would like to know if it is possible to create an HTML form text box
that can draw information out of the database and display it in the
HTML form text box. I have purchased a few books on the integration of
databases and PHP but can find no such example. Maybe there is a better

way of doing this?

My theory is that if I can draw this information from the database and
have it displayed in the HTML form text box, this same information can
be UPDATED if need be from the same page. Any information or a point in

the right direction, again would be appriciated.
Frank

Jul 16 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Rik
fjm67 wrote:
If someone can either direct me to some howto or even provide me with
an example, I would be grateful.

I would like to know if it is possible to create an HTML form text box
that can draw information out of the database and display it in the
HTML form text box. I have purchased a few books on the integration of
databases and PHP but can find no such example. Maybe there is a
better

way of doing this?

My theory is that if I can draw this information from the database and
have it displayed in the HTML form text box, this same information can
be UPDATED if need be from the same page. Any information or a point
in

- Assuming a table tbl_name, with fields id & text
- Displaying and updating all records at once
- Simpified code, without error checking and hence a major security risk:

<form action="<?php echo $_SERVER['PHP_SELF']; ?method="post">
<?php
$con = mysql_connect('host', 'user', 'pass');
mysql_select_db('db',$con);
if(isset($_POST['submit'])){
foreach($_POST['text'] as $id =$text){
mysql_query("UPDATE tbl_name SET `text` = '{$text}' WHERE `id` =
$id");
}
}
$result=mysql_query("SELECT id,text FROM tbl_name");
while($row = mysql_fetch_array($result)){
echo '<textarea
name="text['.$row['id'].']">'.$row['text'].'</textarea>';
}
?>
<input type="submit" name="submit" value="change" />
</form>

If you have purchased some books I assums they will tell you what to do
about safety...

Grtz,
--
Rik Wasmus
Jul 16 '06 #2

P: n/a
Thanks Rik. That helps me a lot.

Frank
Rik wrote:
fjm67 wrote:
If someone can either direct me to some howto or even provide me with
an example, I would be grateful.

I would like to know if it is possible to create an HTML form text box
that can draw information out of the database and display it in the
HTML form text box. I have purchased a few books on the integration of
databases and PHP but can find no such example. Maybe there is a
better

way of doing this?

My theory is that if I can draw this information from the database and
have it displayed in the HTML form text box, this same information can
be UPDATED if need be from the same page. Any information or a point
in


- Assuming a table tbl_name, with fields id & text
- Displaying and updating all records at once
- Simpified code, without error checking and hence a major security risk:

<form action="<?php echo $_SERVER['PHP_SELF']; ?method="post">
<?php
$con = mysql_connect('host', 'user', 'pass');
mysql_select_db('db',$con);
if(isset($_POST['submit'])){
foreach($_POST['text'] as $id =$text){
mysql_query("UPDATE tbl_name SET `text` = '{$text}' WHERE `id` =
$id");
}
}
$result=mysql_query("SELECT id,text FROM tbl_name");
while($row = mysql_fetch_array($result)){
echo '<textarea
name="text['.$row['id'].']">'.$row['text'].'</textarea>';
}
?>
<input type="submit" name="submit" value="change" />
</form>

If you have purchased some books I assums they will tell you what to do
about safety...

Grtz,
--
Rik Wasmus
Jul 17 '06 #3

P: n/a
Rik wrote:
fjm67 wrote:
[SNIP...]
if(isset($_POST['submit'])){
foreach($_POST['text'] as $id =$text){
mysql_query("UPDATE tbl_name SET `text` = '{$text}' WHERE `id` =
$id");
}
}
[SNIP...]

I'm probably missing out on somthing here, but why would one want to do
this? Surely you don't want to update rows depending on user input,
especially when the possible input was based on the data you provided
yourself in the first place?

F
Jul 17 '06 #4

P: n/a
Rik
Frank van Meurs wrote:
Rik wrote:
>fjm67 wrote:
[SNIP...]
>if(isset($_POST['submit'])){
foreach($_POST['text'] as $id =$text){
mysql_query("UPDATE tbl_name SET `text` = '{$text}' WHERE
`id` = $id");
}
}
[SNIP...]

I'm probably missing out on somthing here, but why would one want to
do this? Surely you don't want to update rows depending on user input,
especially when the possible input was based on the data you provided
yourself in the first place?
Euhm, firstly, how do you propose changing a value in a database that needs
to be changed by a user and a webinterface? I'd say by providing them with a
form with a possible input and update the field after a post....

Second, let's quote myself:
"Simpified code, without error checking and hence a major security risk
<snip>
If you have purchased some books I assums they will tell you what to do
about safety..."

I could keep posting fully operational forms with vigurous user- and
datavalidation, but that's normally not the answer to the question. And
allthough I'm posting a lot these days, I DO have something better to do
then providing fully operational code for free :-) (No really, I have a
live, please believe me..).

Grtz,
--
Rik Wasmus
Jul 17 '06 #5

P: n/a
Thanks Rik.

I am very new to PHP. I am trying to understand it so what you and
Frank van Meurs wrote is above my head. By the way, this script is for
interoffice use only. It will not be on the net at all. Should I still
build error checking into it still?

To enlighten Frank van Meurs, I need a form that will allow tupples to
be changed in the database. What if the person's address changes? What
if they change a telephone number? Do you see a better way to do this?
I don't. I'm new to PHP but not to databases.

Thanks again Rik.

Frank

Rik wrote:
Frank van Meurs wrote:
Rik wrote:
fjm67 wrote:
[SNIP...]
if(isset($_POST['submit'])){
foreach($_POST['text'] as $id =$text){
mysql_query("UPDATE tbl_name SET `text` = '{$text}' WHERE
`id` = $id");
}
}
[SNIP...]

I'm probably missing out on somthing here, but why would one want to
do this? Surely you don't want to update rows depending on user input,
especially when the possible input was based on the data you provided
yourself in the first place?

Euhm, firstly, how do you propose changing a value in a database that needs
to be changed by a user and a webinterface? I'd say by providing them with a
form with a possible input and update the field after a post....

Second, let's quote myself:
"Simpified code, without error checking and hence a major security risk
<snip>
If you have purchased some books I assums they will tell you what to do
about safety..."

I could keep posting fully operational forms with vigurous user- and
datavalidation, but that's normally not the answer to the question. And
allthough I'm posting a lot these days, I DO have something better to do
then providing fully operational code for free :-) (No really, I have a
live, please believe me..).

Grtz,
--
Rik Wasmus
Jul 18 '06 #6

ronverdonk
Expert 2.5K+
P: 4,258
Thanks Rik.

I am very new to PHP. I am trying to understand it so what you and
Frank van Meurs wrote is above my head. By the way, this script is for
interoffice use only. It will not be on the net at all. Should I still
build error checking into it still?

To enlighten Frank van Meurs, I need a form that will allow tupples to
be changed in the database. What if the person's address changes? What
if they change a telephone number? Do you see a better way to do this?
I don't. I'm new to PHP but not to databases.

Thanks again Rik.

Frank
Frank,

If you have an hour or so, I am currently developing just the application you are looking for (change an email address in the data base via the HTML text box) and I can send you the code when I'm done. DO you want it?

Ron ::cool:
Jul 18 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.