I would like to output my data to a text file or text file format, with no html. One record per line. I am using the short long mod.
Mar 7, 2000, 10:53 AM
Veteran (17240 posts)
Mar 7, 2000, 10:53 AM
Post #4 of 18
Views: 5235
Yes...In the other format sub-routine, you can format the view any way you like...
For an example go here:
http://www.coco.cc.az.us/...t&sum_schedule=1
Select Art for the Subject and Session I for the Session.
Then click on the View Printable Format button.
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
For an example go here:
http://www.coco.cc.az.us/...t&sum_schedule=1
Select Art for the Subject and Session I for the Session.
Then click on the View Printable Format button.
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Mar 8, 2000, 6:43 AM
Novice (21 posts)
Mar 8, 2000, 6:43 AM
Post #5 of 18
Views: 5221
Hi we want add an additional sub like the printout sub but instead of having it print to a text file we want a html sub with no headers or footers just a table like the long display. We want to print out all the records just as is happening when we sent it to the text file. How do I start this sub do I put it in the same area as the printout sub
Thanks
Thanks
Mar 8, 2000, 7:18 AM
Veteran (17240 posts)
Mar 8, 2000, 7:18 AM
Post #6 of 18
Views: 5250
The better topic to use is the following:
http://www.gossamer-threads.com/...m12/HTML/000534.html
And in the sub html_print_view routine in the html.pl that is where you can put plain text with no header and footer, with the fields that you want to display.
REALLY hope this helps.
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
http://www.gossamer-threads.com/...m12/HTML/000534.html
And in the sub html_print_view routine in the html.pl that is where you can put plain text with no header and footer, with the fields that you want to display.
REALLY hope this helps.
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Mar 8, 2000, 9:46 PM
Novice (21 posts)
Mar 8, 2000, 9:46 PM
Post #7 of 18
Views: 5225
Maybe I making this confusing I would like to modify the proceeding code so that i get a view in table format. Basically like the printout sub but it doesn't send the output to a text file output goes to html without the headers and footers. I want it to follow the sub printout format ie when a checkbox is checked I get all the records printed out in html table format.
Mar 9, 2000, 5:53 AM
Novice (21 posts)
Mar 9, 2000, 5:53 AM
Post #8 of 18
Views: 5226
How do I change this so that is prints all the records in html as apposed to output to text.
sub html_printout {
my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
$output = qq|Insert anything you want as introductory text here.
You can just put carriage returns within the text for new lines.
Be sure to end with \n\n in order to get a double space
Before the start of the record printout.|;
for (0 .. $numhits - 1) {
%rec = &array_to_hash($_, @hits);
$output .= "$rec{'Lastname'} $rec{'Firstname'} $rec{'Parents'}\n";
}
open (TEXT, ">/home/httpd/vhosts/proscouting.com/cgi-bin/data/text.txt") or
&cgierr("error in writing text file. \nReason: $!");
if ($db_use_flock) {
flock(TEXT, 2) or &cgierr("unable to get exclusive lock on text
file.\nReason: $!");
}
print TEXT $output;
close TEXT;
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Text File Saved</title>
</head>
<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500
align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Text File Saved</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>Text File Saved
</b></font></center><P>
<$font>
The text file was successfully saved.</FONT>
<P>|;
&html_footer;
print qq|</td></tr>
</table></center></body></html>|;
}
sub html_printout {
my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
$output = qq|Insert anything you want as introductory text here.
You can just put carriage returns within the text for new lines.
Be sure to end with \n\n in order to get a double space
Before the start of the record printout.|;
for (0 .. $numhits - 1) {
%rec = &array_to_hash($_, @hits);
$output .= "$rec{'Lastname'} $rec{'Firstname'} $rec{'Parents'}\n";
}
open (TEXT, ">/home/httpd/vhosts/proscouting.com/cgi-bin/data/text.txt") or
&cgierr("error in writing text file. \nReason: $!");
if ($db_use_flock) {
flock(TEXT, 2) or &cgierr("unable to get exclusive lock on text
file.\nReason: $!");
}
print TEXT $output;
close TEXT;
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Text File Saved</title>
</head>
<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500
align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Text File Saved</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>Text File Saved
</b></font></center><P>
<$font>
The text file was successfully saved.</FONT>
<P>|;
&html_footer;
print qq|</td></tr>
</table></center></body></html>|;
}
Mar 9, 2000, 4:36 PM
Veteran (17240 posts)
Mar 9, 2000, 4:36 PM
Post #11 of 18
Views: 5207
Oh...okay...then all you have to do is use the following codes:
#-------------------------------------------
# Print Record Routine
my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
print qq|
<html>
<head>
<title>Text View</title>
</head>
<body bgcolor="ffffff">
$rec{'Lastname'} $rec{'Firstname'} $rec{'Parents'}
</body>
</html>
|;
}
That is it.
Good luck!
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
[This message has been edited by AnthroRules (edited March 09, 2000).]
Code:
sub html_printout { #-------------------------------------------
# Print Record Routine
my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
print qq|
<html>
<head>
<title>Text View</title>
</head>
<body bgcolor="ffffff">
$rec{'Lastname'} $rec{'Firstname'} $rec{'Parents'}
</body>
</html>
|;
}
That is it.
Good luck!
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
[This message has been edited by AnthroRules (edited March 09, 2000).]
Mar 9, 2000, 6:59 PM
Veteran (17240 posts)
Mar 9, 2000, 6:59 PM
Post #13 of 18
Views: 5226
UGH....Okay...you need to use the revised codes:
#-------------------------------------------
# Print Record Routine
my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Text View</title>
</head>
<body bgcolor="ffffff">
$rec{'Lastname'} $rec{'Firstname'} $rec{'Parents'}<br>
</body>
</html>
|;
}
Hope this works...and helps.
If not, you will have to save your html.pl and db.cgi as text files, upload them to a publicly accessible directory, and provide the URLs to these text files!
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
[This message has been edited by AnthroRules (edited March 09, 2000).]
Code:
sub html_printout { #-------------------------------------------
# Print Record Routine
my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Text View</title>
</head>
<body bgcolor="ffffff">
$rec{'Lastname'} $rec{'Firstname'} $rec{'Parents'}<br>
</body>
</html>
|;
}
Hope this works...and helps.
If not, you will have to save your html.pl and db.cgi as text files, upload them to a publicly accessible directory, and provide the URLs to these text files!
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
[This message has been edited by AnthroRules (edited March 09, 2000).]
Mar 10, 2000, 5:04 AM
Novice (21 posts)
Mar 10, 2000, 5:04 AM
Post #14 of 18
Views: 5222
Hmm I have put this
<input type="checkbox" name="printout" value="1">
in sub html_search_options
In html_view_success I have the following under my (@hits) = @_;
if ($in{'printout'}) { &html_printout(@hits); return;}
At the end of the viewing section I put your code in. When I select the checkbox and select all the records. I get a blank html page.
What am I doing wrong?
<input type="checkbox" name="printout" value="1">
in sub html_search_options
In html_view_success I have the following under my (@hits) = @_;
if ($in{'printout'}) { &html_printout(@hits); return;}
At the end of the viewing section I put your code in. When I select the checkbox and select all the records. I get a blank html page.
What am I doing wrong?
Mar 10, 2000, 5:18 AM
Veteran (17240 posts)
Mar 10, 2000, 5:18 AM
Post #15 of 18
Views: 5231
The codes I've given you, and the examples I've given you ONLY work with a submit button from the search page and uses its own sub-routines in the db.cgi. I thought the other Topics were quite clear about the changes you have to make in the db.cgi, BUT I guess not...
Here are complete instructions (better bookmark this Topic in case it gets lost and I will not be posting these codes again!):
1) Add the following codes in your sub main routine in midst of the elsif statements in the db.cgi file:
2) Add the following sub-routine in your db.cgi file underneath the sub view_record:
# --------------------------------------------------------
# This is called when a user is searching the database for
# viewing. All the work is done in query() and the routines just
# checks to see if the search was successful or not and returns
# the user to the appropriate page.
my ($status, @hits) = &query("view");
if ($status eq "ok") {
&html_printout(@hits);
}
else {
&html_view_failure($status);
}
}
3) Then in the html_view_search, put in the following submit button:
REALLY hope this works this time!
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Here are complete instructions (better bookmark this Topic in case it gets lost and I will not be posting these codes again!):
1) Add the following codes in your sub main routine in midst of the elsif statements in the db.cgi file:
Code:
elsif ($in{'printout'}) { if ($per_view) { &print_view; } else { &html_unauth; } }2) Add the following sub-routine in your db.cgi file underneath the sub view_record:
Code:
sub print_view { # --------------------------------------------------------
# This is called when a user is searching the database for
# viewing. All the work is done in query() and the routines just
# checks to see if the search was successful or not and returns
# the user to the appropriate page.
my ($status, @hits) = &query("view");
if ($status eq "ok") {
&html_printout(@hits);
}
else {
&html_view_failure($status);
}
}
3) Then in the html_view_search, put in the following submit button:
Code:
<input type="submit" name="print_view" value="1">REALLY hope this works this time!
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Mar 10, 2000, 6:01 AM
Novice (21 posts)
Mar 10, 2000, 6:01 AM
Post #16 of 18
Views: 5231
Ok entered all this. The value you have on the new submitt does it have to be one or can i name it anything? So basically what should happen is that when I bring up the view i will have a second view button. When I click on it it should go to the sub html_printout and I should see the results. Does it matter where the sub html_printout is in the html.pl file? When I click on this second view button we need all the records in one page ie if there is 500 records we want one page with 500 records. Just one glich though I am still getting a blank page with no records just wondering if this has to do with the placement of the sub html_printout , or if I am missing something
Again thanks for your patience
Again thanks for your patience
Mar 10, 2000, 8:24 AM
Veteran (17240 posts)
Mar 10, 2000, 8:24 AM
Post #17 of 18
Views: 5226
Code:
$format_url = $ENV{'QUERY_STRING'}; $format_url =~ s/\&view_records=1/;
Then add the following link in the HTML portion of this sub:
Code:
<a href+"$db_script_url&$format_url&print_view=1">Printable View of Records</a>Code:
open (DB, "<$db_file_name") or &cgierr("unable to open db file: $db_file _name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>;
close DB;
$number_of_records = scalar(@lines);
Then add the following codes after these codes before the my ($numhits) codes:
Code:
if ($in{'print_view'}) { $maxhits = $number_of_records;
}
then add the following codes before my ($numhits):
Code:
else {Then after the next line after my ($numhits), add a right bracket...
So, the codes should look like the following:
Code:
if ($in{'print_view'}) { $maxhits = $number_of_records;
}
else {
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_
hits);
}
And about printing the records, are you using there is one more sub-routine that you need to add called html_printout, which needs to be a copy of the sub html_view_success without the header and footer codes in it. Then replace the current sub-routine called sub html_printout to sub html_printout_record, and take out the extranous HTML codes including the <html> stuff...Just include the fields you want to print.
Then it should work.
Regards,
------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums