Gossamer Forum
Home : Products : DBMan : Customization :

More Short/Long mod trouble

Quote Reply
More Short/Long mod trouble
I am using DBMan at http://www.actiondb.cjb.net (AQ2 DB) and am having trouble with the short/long displaying. I have little/no knowledge of CGI and am stuck.
I have got this :
Code:
my (%rec) = @_;
($db_auto_generate and print &build_html_record(%rec) and return);
$rec{$db_key} =~ s/<.?B>//g;
$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";

Are you sure this works? When I click on a link that this gives I get a blank page with the next/prev buttons...
Quote Reply
Re: More Short/Long mod trouble In reply to
That's what I have on my database and it works just fine.

There are a number of reasons you might end up with a blank page. The first thing to look for is your table formatting in html_record_long. Make sure that you have </td></tr></table> at the end of your subroutine.

If that doesn't seem to solve your problem, I'll need to see the database in action. Please post a URL where I can take a look at it.


------------------
JPD





Quote Reply
Re: More Short/Long mod trouble In reply to
here is the entire piece of code. I have changed the Database so it is running this code at http://lightning.shadowlands.net/...elb/db.cgi?db=action
log on as guest/guest.
Code:
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.
# This is the "short display" -- the list of records that are returned
# from a search.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
$rec{$db_key} =~ s/<.?B>//g;

# 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{'Nick'}</a>
|;

# if you want to display your fields in columns, use the following format:
# print qq|
# $rec{'Field'}</td>
# <td>$rec{'Field'}</td>
# <td>$rec{'Field'}</td>
# <td>$rec{'Field'}|;

# Add or remove columns as needed. Be sure you add the $long_url link to one of your fields

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

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

}

sub html_record_long {
#----------------------------------------------------------------
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 width=100%>
<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>
|;
}

# Below is where you define your form.

# <-- Start of record display -->


my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
$rec{$db_key} =~ s/<.?B>//g;

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#FFFFFF';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#FFFFFF';

print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#000000">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Nick:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Nick'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Name:</FONT></TD>
<TD> <$font>$rec{'Name'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Homepage:</FONT></TD>
<TD> <$font><A HREF="$rec{'Homepage'}">$rec{'Homepage'}</A></Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Clan: </FONT></TD>
<TD> <$font><a href="$rec{'Clanpage'}">$rec{'Clan'}</a></Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>DOB:</FONT></TD>
<TD> <$font>$rec{'DOB'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>ICQ:</FONT></TD>
<TD> <$font>$rec{'ICQ'} <A HREF="http://msg.mirabilis.com/scripts/contact.dll?msgto=$rec{'ICQ'}">
<img src="http://wwp.icq.com/scripts/online.dll?icq=$rec{'ICQ'}&img=5" VALIGN="center"></a></Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Weapon:</FONT></TD>
<TD> <$font>$rec{'Weapon'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Item:</FONT></TD>
<TD> <$font>$rec{'Item'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Map:</FONT></TD>
<TD> <$font>$rec{'Map'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Comments:</FONT></TD>
<TD> <$font>$rec{'Comments'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email:</FONT></TD>
<TD> <$font><A HREF="mailto:$rec{'Email'}">$rec{'Email'}</A></Font></TD></TR>
|;
# to close off a previous print qq| statement
$ALLOWED_EXT =~ s/\\.//g;
$ALLOWED_EXT =~ s/\$//g;
@extensions = split (/\Q|\E/o,$ALLOWED_EXT);
GRAPHIC: foreach $extension (@extensions) {
if (-e "$SAVE_DIRECTORY/$rec{$db_key}.$extension") {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Picture:</FONT></TD>
<TD> <$font><a href="$SAVE_DIRECTORY_URL/$rec{$db_key}.$extension">Click for picture.</a></Font></TD></TR>
|;
last GRAPHIC;
}
}
print qq|
</TABLE>
|;
}

thanks
Quote Reply
Re: More Short/Long mod trouble In reply to
Looks to me like your problem could be in sub html_view_success. Please copy your html.pl file to a web-accessible directory (one where you would place html files) and rename it to html_pl.txt. Then come back and tell me where I can view it.



------------------
JPD





Quote Reply
Re: More Short/Long mod trouble In reply to
you can view html_pl.txt here http://lightning.shadowlands.net/michaelb/html_pl.txt

Thanks for your time btw Smile
Quote Reply
Re: More Short/Long mod trouble In reply to
You're going to run into some other trouble because you didn't use the entire short/long mod. I wrote it as an entire html.pl file because there are a lot of little things you need to change in addition to the display subroutines.

You really need to go through each of the subroutines and see what is different about them.

For now, in sub html_view_success, you need to change

Code:
if ($db_next_hits) {
print "<br><$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 "<br><$font>Pages: $db_next_hits</font>";
}

to

Code:
# Go through each hit and convert the array to hash and send to
# html_record for printing.
if (($db_total_hits == 1) &#0124; &#0124; ($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 "<br><$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 "<br><$font>Pages: $db_next_hits</font>";}
}

That should fix your immediate problem.


------------------
JPD





Quote Reply
Re: More Short/Long mod trouble In reply to
Half of the problem is fixed, thankyou. The table is now displayed but there is no information in it Smile
The new perl is in the same place as before...
Another problem I am having is people with default priveleges (1,1,1,1,0) cannot modify/delete their records.
I dont think I have fiddled with that piece of code so I am at a bit of a loss.
Thanks
Quote Reply
Re: More Short/Long mod trouble In reply to
If the information is not displaying on the page, check the source code for the page. When you're looking at the results page, right click on the browser window and select "View Source" from the menu.

If you see the data within the source, your problem is somewhere in your creation of tables in html_record_long. You probably have forgotten to put in a </table> tag or something.

If the data is not within the source, my guess is that there is a problem with your $db_key value.

Quote:
people with default priveleges (1,1,1,1,0) cannot modify/delete their records.

In order for someone to be able to modify or delete their own records, there must be some sort of identifier so that the script will know whose records belong to whom. The way that DBMan does this is to use a userid. But in order to use a userid, the user must log in. A default user can not modify or delete his own records.


------------------
JPD





Quote Reply
Re: More Short/Long mod trouble In reply to
When looking at the source for the results display there is no information inside the HTML...
Quote Reply
Re: More Short/Long mod trouble In reply to
Fixed it Smile
Thanks for all your help JPD.
I'll probably be posting again soon if I cannot get the delete/modify working