|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
I was wondering how I can get my database
variables back into the form input fields so a user can modify the data. Anyone have a solution? |
|
#2
|
|||
|
|||
|
You simply print them out with the rest of the HTML you output.
|
|
#3
|
|||
|
|||
|
I guess I am not clear...
What I am trying to say is... If I have a form that has 5 fields that a user can input information which is dumped into a Mysql database. Lets say this database has 100 records and we want to modify one of the records. I would like the values of that record passed back to the form to appear in the field boxes so the user can just modify the field they want instead of entering all the info again into the form. |
|
#4
|
|||
|
|||
|
have your script output the form markup and when you get to the text inputs do this :
<input type="text" name="fieldName" value="$recordValue1"> and so on... RyanP [This message has been edited by RyanP (edited June 25, 2000).] |
|
#5
|
||||
|
||||
|
I would like the values of that record passed back to the form to appear in the field boxes so the user can just modify the field they want instead of entering all the info again into the form. You can do that very easily. Just see the following example.Modify as per your requirment.. #fetch.cgi #!/usr/bin/perl use CGI; use DBI; $q=new CGI; $somevalue=$q->param('fieldname'); #get the input from the formfield. print $q->header; $dbh=DBI->connect('dbi:mysql:databasename','username','pwd'); #connect to the database .. #enter your database name ,username and password to the connection string.. $sql="SELECT * FROM tblname WHERE field='$somevalue'"; #print "Database Connectedn"; $sth = $dbh->prepare($sql) or die "Can't prepare $sql: $dbh->errstrn"; #pass sql query to database handle.. $rv = $sth->execute or die "can't execute the query: $sth->errstrn"; #execute your query if ($rv==0){ #no rows fetched.. print "No such record is available for editingn"; }else{ #record is fetching for modification.. print "<form action="edit.cgi" method="post">n"; while(@row = $sth->fetchrow_array) { Name :<input type="text" name="name" value="$row[0]">n"; #print first column value from database field to text box for editing. ##.... } print "<input type="submit" name="submit" value="Edit This Record">n"; print "</form>n"; } ------------------ SR - shiju.dreamcenter.net "The fear of the LORD is the beginning of knowledge..." [This message has been edited by Shiju Rajan (edited June 25, 2000).] |
|
#6
|
|||
|
|||
|
Did this work Ryan?
Ryan, did you ever get this to work, I'm trying to do the same thing but don't understand some of the code he gave you.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Getting Values from Mysql into a form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|