i should dispay a retrieved value from mysql database in a text field on clicking a button in perl..please any one help me
I am newbie to perl
Collapse
X
-
Tags: None
-
Why don't you try writing this and see how far you get before you get stuck. It involves DBI elements, as well as elements of CGI programming, but its not aweful if you can read the documentation.
If you get stuck or have errors you cannot troubleshoot, simply paste your code into this thread and we will try to help and guide you.
Regards,
Jeff -
Code:#!/usr/bin/perl package C4::test123; use DBI; use strict; use CGI; require Exporter; my $q=new CGI; my $somevalue=$q->param('fieldname'); #get the input from the formfield. print $q->header; print "Content-type: text/html\n\n"; print "<html><h1>Hello!</h1></html>\n"; # Connect to the database # See footnote 1 my $dbh = DBI->connect('DBI:mysql:sample228', 'koha', 'koha') or die "Couldn't open database: $DBI::errstr; stopped"; # Prepare the SQL query for execution my $sth = $dbh->prepare(<<End_SQL) or die "Couldn't prepare statement: $DBI::errstr; stopped"; SELECT author, title, notes FROM biblio WHERE author = 'james' End_SQL # Execute the query $sth->execute() or die "Couldn't execute statement: $DBI::errstr; stopped"; while(my @row = $sth->fetchrow_array) { print STDOUT "Field 1:$row[0] Field 2: $row[1] Field 3: $row[2]\n"; print $q->textfield('field_name','$row[0]',50,80); my $value = $q->param('foo'); $q->param('foo',"I'm taking over this value!"); print $q->submit('button_name','value'); } # Disconnect from the database $dbh->disconnect();
Last edited by numberwhun; Aug 14 '12, 06:46 PM. Reason: Please use code tags around code you place in the forums.Comment
-
-
hi,
to use perl you first have to know what is it? and how it works?
what are the differences? e.t.c and that's why i think you should visit this link: http://www.techyv.com/questions/ques...tween-versions
this will give you ideas of where to use it and how.Comment
Comment