473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

I am newbie to perl

i should dispay a retrieved value from mysql database in a text field on clicking a button in perl..please any one help me
Aug 14 '12 #1
4 1616
numberwhun
3,509 Expert Mod 2GB
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
Aug 14 '12 #2
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. package C4::test123;
  3. use DBI;
  4. use strict;
  5. use CGI;
  6. require Exporter;
  7. my $q=new CGI;
  8. my $somevalue=$q->param('fieldname');
  9. #get the input from the formfield.
  10.  
  11. print $q->header;
  12.  
  13.       print "Content-type: text/html\n\n";
  14.        print "<html><h1>Hello!</h1></html>\n";
  15.  
  16. # Connect to the database
  17. # See footnote 1
  18. my $dbh = DBI->connect('DBI:mysql:sample228', 'koha', 'koha')
  19.     or die "Couldn't open database: $DBI::errstr; stopped";
  20.      # Prepare the SQL query for execution
  21. my $sth = $dbh->prepare(<<End_SQL) or die "Couldn't prepare statement: $DBI::errstr; stopped";
  22. SELECT author, title, notes FROM biblio WHERE author = 'james'
  23. End_SQL
  24.  
  25. # Execute the query
  26.  $sth->execute() or die "Couldn't execute statement: $DBI::errstr; stopped";
  27.  
  28.  
  29.  
  30. while(my @row = $sth->fetchrow_array) {
  31.  
  32. print STDOUT "Field 1:$row[0]  Field 2: $row[1]  Field 3: $row[2]\n";
  33.  
  34. print $q->textfield('field_name','$row[0]',50,80);
  35. my $value = $q->param('foo');
  36.  $q->param('foo',"I'm taking over this value!");
  37.  print $q->submit('button_name','value');
  38.      }
  39. # Disconnect from the database
  40. $dbh->disconnect();
Aug 14 '12 #3
numberwhun
3,509 Expert Mod 2GB
Did you receive errors when running your code? Sorry, we cannot read your mind.
Aug 15 '12 #4
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.
Aug 16 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

42
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time....
3
by: lonelyplanet999 | last post by:
Hi, I'm a newbie to perl and is now studying about perl programming, I read some perl programming tutorials online (enter 'Perl tutorial' at google.com) and also find some sample perl scripts...
2
by: Kevin Horton | last post by:
I'm a perl newbie, with next to no programming experience (I did a bunch of Fortran 25 years ago, but nothing since). I have a problem I need to solve, and I'm wondering whether perl is the best...
1
by: daniel kaplan | last post by:
i am a newbie PERL programmer, oldtime C guy here....anyway, i am starting some PERL scripts on a shared LINUX server. i cannot store my MySQL login parametrs in the apache config, since it is...
4
by: Firewalker | last post by:
Hey guys, I am newbie to perl. I am trying to deal with dates ( such trying to find what the date would be after month). Is therea function or date class( I am a java programmer, I couldnt find...
6
by: Danny Lu | last post by:
Hi, can anyone tell me where I can get a good perl book? TIA Dan
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
4
crystal2005
by: crystal2005 | last post by:
Hello guys.... I'm newbie in Perl Language. So, in here i would like to ask several questions about Perl itself and not about the coding. I have been given a task to use Perl for directory...
8
by: Palindrom | last post by:
Hi everyone ! I'd like to apologize in advance for my bad english, it's not my mother tongue... My girlfriend (who is a newbie in Python, but knows Perl quite well) asked me this morning why...
10
by: Mladen Gogala | last post by:
I am a Python newbie who decided to see what that Python fuss is all about. Quite frankly, I am a bit perplexed. After having had few months of experience with Perl (started in 1994 with Perl v4,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.