Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old June 24th, 2000, 08:39 PM
razormind razormind is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 6 razormind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to razormind
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?

Reply With Quote
  #2  
Old June 25th, 2000, 11:20 AM
dwarf dwarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 300 dwarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
You simply print them out with the rest of the HTML you output.

Reply With Quote
  #3  
Old June 25th, 2000, 03:35 PM
razormind razormind is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 6 razormind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to razormind
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.

Reply With Quote
  #4  
Old June 25th, 2000, 07:15 PM
RyanP
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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).]

Reply With Quote
  #5  
Old June 25th, 2000, 09:44 PM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 9
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

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).]

Reply With Quote
  #6  
Old February 28th, 2001, 10:45 PM
vibajajo vibajajo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 2 vibajajo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Getting Values from Mysql into a form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway