|
-
Mar 17th, 2002, 12:34 AM
#1
Thread Starter
Member
pulling into a textbox...
I'm sorry to keep buggin everyone with my questions... but the book that I have is not advanced enough for what I am trying to do, and i have not had the opportunity to get a better one. At the moment I am trying to pull a bunch of information out of a database and put it in text boxes so the information can be edited.. and then click an update button and have all information be updated in the db.. i have the code to pull it from the DB, but it does not allow for editing, it is just displayed on the screen.. thanks for your help everyone.
Sometimes the simplest things are the hardest...
-
Mar 17th, 2002, 09:05 AM
#2
New Member
I'm new to this to but this is the kinda thing I'd do:
Code:
<?php
if($submit){
$updateSql = "UPDATE someTable SET text='".$text."', title='".$title."' WHERE someCondition";
mysql_query($updateSql);
}else{
?>
<form action="<?php echo $PHP_SELF; ?>">
<input type="text" name="text">
<input type="text" name="title">
<input type="sumbit" name="submit">
</form>
<?php
}
?>
The values of the textboxes could be set to the information you pulled from the DB.
This is pretty stripped down. No error handling etc but maybe you get some ideas from it
-
Mar 17th, 2002, 12:14 PM
#3
Originally posted by I Robert I
I'm new to this to but this is the kinda thing I'd do:
Code:
<?php
if($submit){
$updateSql = "UPDATE someTable SET text='".$text."', title='".$title."' WHERE someCondition";
mysql_query($updateSql);
}else{
?>
<form action="<?php echo $PHP_SELF; ?>">
<input type="text" name="text">
<input type="text" name="title">
<input type="sumbit" name="submit">
</form>
<?php
}
?>
that will not work.
$updateSql = "UPDATE someTable SET text='".$text."', title='".$title."' WHERE someCondition
can't have .$text. will do nothing. just $text will do fine.
but you were close. so if you want the fields to go into teh input boxes you have to give them values.
so you connected to the database and you found the id you want to display. then just add that to the form.
<form action="<?php echo $PHP_SELF; ?>">
<input type="text" name="text" value="<? $namevalue ?>">
<input type="text" name="title" value="<? $titlevalue ?>">
<input type="sumbit" name="submit">
-
Mar 17th, 2002, 01:07 PM
#4
New Member
Strange cause that syntax works absolutely fine for me I use it all the time in my current project (http://bender.homeftp.net:4224/) and I have had NO problems what so ever.
-
Mar 17th, 2002, 04:59 PM
#5
well I didn't say that very well. I meant it will work but no need to use it like that. the "." means you are adding things to it, in this case you are not, so why have it in there.
-
Mar 17th, 2002, 07:07 PM
#6
New Member
Oh, ok. Well I guess my reason is that it makes em stand out in my editor due to syntax highlighting. Kinda like when the variables stand out from the rest of the code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|