Gossamer Forum
Home : Products : DBMan : Discussions :

Display Record

Quote Reply
Display Record
From a view operation, I display a list of records selected. I want to have a Display More button on each line, the button is there. But when the button is pressed, nothing happens!

Here is the code I have for the form:

sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.

## warren was here ($db_auto_generate and print &build_html_record(%rec) and return);
## commented out by web to stop the auto generation of the forms.


$submit_button = "Display More";

print qq|

<TABLE WIDTH="100%" CELLPADDING=1 CELLSPACING=1 BORDER=0>


<TR>
<td width=7%>$rec{'propid'}</td>
<td width=10%>$rec{'location'}</td>
<td width=15%>$rec{'area'}</td>
<td width=40%>$rec{'text'}</td>
<td width=10%>$rec{'price'}</td>
<td width=18%><input type=hidden name="$db_key" value="$rec{'refno'}">
<INPUT TYPE="SUBMIT" NAME="html_add_success" VALUE="$submit_button"></td>

</TR>

</TABLE>

|;
}


And assistance would be appreciated.

Thank you in advance.

Quote Reply
Re: Display Record In reply to
Have you by any chance checked out the Short/Long mod in the Resource Center?

That mod will setup your display exactly how you want it. Showing just a few fields on an intial listing of records, and then clicking on links to view the full record display.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Display Record In reply to
Thanks for your response. But when I go to: Short/Long display of search results -- "user friendly" html.pl or the entry below it, I get an error message saying the URL is not found. So I have found the location for the answer to my question, but still cannot get the answer. Do you have another suggestion? Thanks, WB_Samui

Quote Reply
Re: Display Record In reply to
Looks like maybe JPDeni's server is down. Here is a copy of the mod.

http://www.jpdeni.com/dbman/Mods/short_change.txt

#####################################################################
# Short/Long Display from regular html.pl file
# by JPDeni
# Last Modified: 1 May 2000
#
######################
#
# Some folks have asked how to adapt the html.pl file to short/long display, instead of downloading a new html.pl file. Here's the procedure.
#
# Step 1:
# rename sub html_record to sub html_record_long
#
# Step 2:
# In sub html_record_long (the one you just renamed), add the following just after
#
# my (%rec) = @_;

#-------------------------------

if ($db_total_hits > 1) {
# create links to previous and next records
$next_url = $ENV{'QUERY_STRING'};
$next_url =~ s/\&nh=\d+//;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;
if ($prev_hit) {
$previous = qq~<a href="$db_script_url?$next_url&nh=$prev_hit"><$font>Previous</font></a>~;
}
else { $previous = " "; }
if ($next_hit <= $db_total_hits) {

$next = qq~<a href="$db_script_url?$next_url&nh=$next_hit"><$font>Next</font></a>~;
}
else { $next = " "; }
# create link back to short display
$list_url = $next_url;
$list_url =~ s/\&mh=\d+//;
$mh = $db_max_hits;
$lh = int(($nh-1)/$mh) + 1;
$list = qq~<a href="$db_script_url?$list_url&nh=$lh"><$font>Back to record list</font></a>~;
# print out the links
print qq|
<table>
<tr><td width=50%>$previous</td>
<td width=50% align=right>$next</td></tr>
<tr><td colspan=2 align=center>$list</td></tr>
<tr><td colspan=2 align=center><$font>Record $nh of $db_total_hits</font></table>
|;
}
#-----------------------------

# Step 3:
# Create a new subroutine -- sub html_record
#------------------------------

sub html_record {
# --------------------------------------------------------
# This is the "short display" -- the list of records that are returned
# from a search.
my (%rec) = @_;

# create link to full display
$record_number = ((($nh - 1) * $db_max_hits) + $i);

$long_url = $ENV{'QUERY_STRING'};
$long_url =~ s/\&nh=\d+//;
$long_url =~ s/\&mh=\d+//;
$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1";

print "<TD>"; # do not remove this! It is necessary to make the records display properly

# Below is where you define what you want to appear for each record in the "short" display.
# You can make this whatever you want, and display as many fields as you would like.
# Choose which of the fields you would like for users to click on to reach the full display
# of records and use that field name in place of "Title" below.
#
# Be sure that you use <a href="$long_url"> for the link to your full record display.
# <-- Start of short display formatting -- >

print qq|
<a href="$long_url">$rec{'Title'}</a>
|;

# <-- End of short display formatting -- >

print "</TD>"; # do not remove this! It is necessary to make the records display properly
}
#-------------------

# Step 4
# In sub html_view_success, after

my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

# add

$in{'nh'} ? ($nh = $in{'nh'}) : ($nh = 1);

# Change

#------------------
if ($db_next_hits) {
print "
<$font>Pages: $db_next_hits</font>";
}

# Go through each hit and convert the array to hash and send to html_record for printing.
for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}
if ($db_next_hits) {
print "
<$font>Pages: $db_next_hits</font>";
}
#------------------

# to

#------------------
if (($db_total_hits == 1) or ($maxhits == 1)) {
&html_record_long(&array_to_hash(0, @hits));
}
else {
print qq|<p><$font>Your search returned <b>$db_total_hits</b> matches.</font>|;
if ($db_next_hits) { print "
<$font>Pages: $db_next_hits</font>"; }
$i = 1;
print "<table>";
for (0 .. $numhits - 1) {
print "<tr>";
&html_record (&array_to_hash($_, @hits));
print "</tr>";
++$i;
}
print "</table>";
if ($db_next_hits) { print "
<$font>Pages: $db_next_hits</font>";}
}
#--------------------------

# In sub html_delete_form, after

my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

# add

$in{'nh'} ? ($nh = $in{'nh'}) : ($nh = 1);

# Change

#-------------------
if ($db_next_hits) {
print "
<$font>Pages: $db_next_hits</font>";
}
if ($status ne "ok") { # There was an error searching!
print qq|<P><FONT COLOR="RED" SIZE=4>Error: $status</FONT></P>|;
}
else {
print "<P>";
for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
print qq|<TABLE BORDER=0><TR><TD><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="delete"></TD><TD>|;
&html_record (%tmp);
print qq|</TD></TR></TABLE>\n|;
}
if ($db_next_hits) {
print "
<$font>Pages: $db_next_hits</font>";
}
}
#---------------
# to
#---------------
if ($status ne "ok") { # There was an error searching!
print qq|<P><FONT COLOR="RED" SIZE=4>Error: $status</FONT></P>|;
}
else {
if (($db_total_hits == 1) or ($maxhits == 1)) {
print qq|
<p><$font>
If you would like to delete this record, check the box and then press "Delete Records":</font>|;
%tmp = &array_to_hash(0, @hits);
print qq|<table><tr><td valign=top><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="delete"></td><td>|;
&html_record_long(&array_to_hash(0, @hits));
print qq|</td></tr></table>
|;
}
else {
print qq|
<p><$font>
Check which records you wish to delete and then press "Delete Records":

Your search returned <b>$db_total_hits</b> matches.</font>
|;
if ($db_next_hits) { print "
<$font>Pages: $db_next_hits</font>"; }
$i = 1;
print "<table>";
for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
print qq|<TR><TD valign=top><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="delete"></TD>|;
&html_record (%tmp);
print "</tr>";
++$i;
}
print "</table>";
if ($db_next_hits) { print "
<$font>Pages: $db_next_hits</font>"; }
}
}
#------------------

# In sub html_modify_form, after

my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

# add

$in{'nh'} ? ($nh = $in{'nh'}) : ($nh = 1);

# Change

#---------------------
if ($db_next_hits) {
print "
<$font>Pages: $db_next_hits</font>";
}
# Go through each hit and convert the array to hash and send to html_record for printing. Also add a radio button with name=modify and value=key.
if ($status ne "ok") { # Error searching database!
print qq|<P><FONT COLOR="RED" SIZE=4>Error: $status</FONT>|;
}
else {
print "<P>";
for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
print qq|<TABLE BORDER=0><TR><TD><INPUT TYPE=RADIO NAME="modify" VALUE="$tmp{$db_key}"></TD><TD>|;
&html_record (%tmp);
print qq|</TD></TR></TABLE>\n|;
}
if ($db_next_hits) {
print "
<$font>Pages: $db_next_hits</font>";
}
}
#-----------------

to

#-----------------
if ($status ne "ok") { # Error searching database!
print qq|<P><$font_error>Error: $status</FONT>|;
}
else {
print qq| <p><$font>
Check which record you wish to modify and then press "Modify Records":
Your search returned <b>$db_total_hits</b> matches.</font>
|;
if ($db_next_hits) { print "
<$font>Pages: $db_next_hits</font>"; }
$i = 1;
print "<table>";
for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
print qq|<TR><TD valign=top><INPUT TYPE=RADIO NAME="modify" VALUE="$tmp{$db_key}"></TD>|;
&html_record (%tmp);
print "</tr>";
++$i;
}
print "</table>";
if ($db_next_hits) { print "
<$font>Pages: $db_next_hits</font>"; }
}
#--------------


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Display Record In reply to
OK, thanks for the help. I will figure this out!