Gossamer Forum
Home : Products : DBMan : Installation :

JPD or Norm (you still out there?) short vs long Display

Quote Reply
JPD or Norm (you still out there?) short vs long Display
Quote "I am doing something similar on one of my databases, but going about it a little differently. If a search results in 1 hit, it goes to the "long" record. Otherwise it
goes to the "short" record. I haven't tried it out yet, though, so I'm not sure how it's going to work. "

I've been digging in the forum old records but I only come across your messages and never did find a hard copy of the final output- Yup even visited NOrm's remax site -- not bad I can't wait till I get my DBMAN to do that. But I really could use your help !!! Would you pretty please with sugar on top post your coding to break up search display into first then long views. I'm going to keep digging but the archieves don't have the ease of use as the current daily forum does. lost of time and digging involved :-( But at least I'm not wasting time over useless messages. I always get something out them.

Thanks in advance

------------------
Thanks for everything !
Quote Reply
Re: JPD or Norm (you still out there?) short vs long Display In reply to
 Smile What I did was the following:

My whole html_view_success subroutine--

Code:
sub html_view_success {
my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

if ( $db_total_hits == 1 ) {
&html_record_text(&array_to_hash($_, @hits));
}
else {
&html_print_headers;
print qq|<html><head><title>$html_title: Search Results.</title></head>$top|;
&header;
print qq|<P align=center><$font_subtitle>Search Results</font>$bar
<p><$font>
Your search returned <b>$db_total_hits</b> matches.</font>
|;
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.
print qq|<CENTER><TABLE>|;
for (0 .. $numhits - 1) {
&html_record (&array_to_hash($_, @hits));
}
print "</TABLE></CENTER>";
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
&footer;
print $bottom;
}
}

Now for a little explanation of the above.

The subroutine &html_record_text is called when there's one hit. It contains everything for the page -- &html_print_headers, <html>, the body tag as well as the closing tags.

There are some other variables in there that I added -- $top and $bottom -- and subroutines &header and &footer that create the format for the pages, including <html> and the other necessary tags.

What you're interested in, though, is after
# Go through each hit and convert the array to hash and send to
# html_record for printing.


I decided to put the results into one table, with each result in its own table row, so before I go through the hits, I started the <table> definition. And then when everything's been printed, I closed off the table.

html_record is as follows:

Code:
sub html_record {
my (%rec) = @_;
print qq|
<TR><TD Align="Right"><$font><B>$rec{'first'} $rec{'last'}</B></font></TD>
<TD><$font><B>
<a href="$db_script_link_url&ww=on&ID=$rec{'ID'}&view_records=1">|;
if ( $rec{'pre'} ) { print qq|$rec{'pre'} |; }
print qq|$rec{'title'}</a></B></font></td></tr>|;
}

This database is for poems and essays, so I have the writer's first name and last name and the title of the work. The "pre" field is for words like "The," "A" and "An," so they aren't considered when a search is made on the title.

Don't hesitate to ask if you have any questions. Smile



------------------
JPD
Quote Reply
Re: JPD or Norm (you still out there?) short vs long Display In reply to
Am I going to be happy? So, let me get this straight, if the search only returns 1 hit it'll show the full recored and if there are more than 1 you get a table with clickable URLs? Even this alone will make me happy. But, in Norm's example his view form is relatively big compared to the screen, is it possible to have the user to choose from the first (short) list and then have multiple outputs on the second run through (my view forms are only about a quarter of the screen) using checkboxes? Also, is this what you 2 came up with back in September, the code looks a little different.

Jeez, if I get everything just jiffy I'm going to owe you a big cup of java (no pun in tended :-).

------------------
Thanks for everything !
Quote Reply
Re: JPD or Norm (you still out there?) short vs long Display In reply to
 
Quote:
is this what you 2 came up with back in September, the code looks a little different.

The code that Norm came up with is not the same as mine. What happened was he asked about how to do it, which gave me the idea to use something similar on my site. I worked out the procedure myself before I came back to the forum to see what the response to Norm had been. (At least that's how I remember it. Smile ) There's more than one way to skin a -- oops, my feline friends are watching. Better not finish that!

Quote:
if the search only returns 1 hit it'll show the full recored and if there are more than 1 you get a table with clickable URLs?

Yep. You can see how mine works by going to my site at
http://www.drizzle.com/~hall/cgi-bin/dbman/db.cgi?db=write&uid=default

Choose one of the drop-down lists -- in the "Author QuickSearch" the "H" has a number of entries. You'll see just how it works.

Quote:
is it possible to have the user to choose from the first (short) list and then have multiple outputs on the second run through (my view forms are only about a quarter of the screen) using checkboxes?

I hesitate to say that anything isn't possible. I wouldn't know how to do it. The problem is that the search is done on the key field and you can't (as far as I know) enter more than one value for each field, and what you are asking would be, in effect, "search for ID 123 and 456 and 789."

After thinking about it a bit, I guess you could, using something similar to the way the delete_record subroutine finds multiple records by using checkboxes. It would entail writing a different search routine, though.

Quote:
if I get everything just jiffy I'm going to owe you a big cup of java (no pun in
tended :-)

Smile Well, I don't know if we can get it exactly like you want, but if we do, please make that a cup of Earl Grey, hot, no milk, no sugar! :-)



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


[This message has been edited by JPDeni (edited January 31, 1999).]