Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

How to write a CGI program to fetch data from mysql database and show in the browser with values in the text field?

by sanjay nayak (Sexton)
on Nov 04, 2008 at 07:19 UTC ( [id://721294]=perlquestion: print w/replies, xml ) Need Help??

sanjay nayak has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: How to write a CGI program to fetch data from mysql database and show in the browser with values in the text field?
by CountZero (Bishop) on Nov 04, 2008 at 07:32 UTC
    Smells like homework ...

    Anyhow, have a look at modules such as Catalyst or CGI::Application or any Templating module and combine it with e.g. DBIx::Class. It probably takes less than 20 lines of code to do what you want.

    So show us some effort and we can help you further.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: How to write a CGI program to fetch data from mysql database and show in the browser with values in the text field?
by marto (Cardinal) on Nov 04, 2008 at 09:25 UTC

    By "Can anyone suggest me a suitable code for it.", do you really mean "Can someone do this for me please?"? Did you read the answers to your previous post "How to use perl CGI programs with mysql server?"? Example code is provided in the tutorials I linked to. You have not posted any of your own code, we can only assume you have not attempted anything yet.

    Martin

Re: How to write a CGI program to fetch data from mysql database and show in the browser with values in the text field?
by romandas (Pilgrim) on Nov 04, 2008 at 08:31 UTC
    I humbly suggest that for one to get help, one should try helping oneself first -- show us some code or even some pseudocode.
Re: How to write a CGI program to fetch data from mysql database and show in the browser with values in the text field?
by ig (Vicar) on Nov 04, 2008 at 15:45 UTC

    It sounds like you are looking for an application framework to help you build a web interface for CRUD.

    There are many application frameworks that facilitate developing web applications with databases. Try searching for CRUD and/or application framework here or on Google to get some leads, including surveys and comparisons of features.

    Your initial difficulty may be the number of choices available and the time required to learn any of them well enough to make an informed decision. You will also learn that there are some very strong opinions for and against almost every one of them, rather than a consensus of what is best. So you will have some work to do to decide what to use and how to proceed.

Re: How to write a CGI program to fetch data from mysql database and show in the browser with values in the text field?
by sanku (Beadle) on Nov 04, 2008 at 11:08 UTC
    hi try out this one,
    #!/usr/bin/perl use CGI qw(:standard); use strict; use warnings; use DBI; print "Content-type:text/html\n\n"; my $i; my $dbh= DBI->connect('DBI:mysql:databasename','root','password'); my $sth=$dbh->prepare("select * from emp_info"); $sth->execute(); print "<html><head></head><body><form name=frm1><table border=1>"; while(my @arr=$sth->fetchrow_array()) { print "<tr><td>Id = $arr[$i]</td>"; print "<td>Name = $arr[$i+1]</td>"; print "<td>Age = $arr[$i+2]</td>"; print "<td>Salary = $arr[$i+3]<td></tr>"; } print "</table></form></body></html>";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://721294]
Approved by Sixtease
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-03-28 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found