Gossamer Forum
Home : Products : DBMan : Installation :

0-9 & A-Z Listing of Search Results - Any Ideas???

Quote Reply
0-9 & A-Z Listing of Search Results - Any Ideas???
Hello,

Can someone get me pointed in the right direction with search results?

I would like to have a link on my home page that says something like "A-Z List". When you click on that link a new page opens up with "0-9 A B C D" etc... Each of these will be linked to a search page that will, for example, list all of the companies in the database that start first with the numbers "0-9" (like 123HostMe.com) and then letter "A", and so on.

I'm using the user friendly html.pl and the short/long list modifications. When the "A" search results come back they need to be listed in the short "spreadsheet" format, which is in turn links to the longer format.

Any help would much appreciated!!!

------------------
Chad Roadhouse
NitroMax Web Hosting
http://nitromax.com/index.html
Quote Reply
Re: 0-9 & A-Z Listing of Search Results - Any Ideas??? In reply to
Here's what I did. On the page that you want to list your letters and numbers, add

Code:
print qq|<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%"><TR>|;

for ($i=48; $i<=57; ++$i) {
print qq|<TD><PRE><A HREF="$db_script_link_url&Name=%5E|;
print chr($i);
print qq|&re=on&view_records=1"><B>|;
print chr($i);
print qq|</B></A></PRE></TD>\n|;
}

for ($i=65; $i<=90; ++$i) {
print qq|<TD><PRE><A HREF="$db_script_link_url&Name=%5E|;
print chr($i);
print qq|&re=on&view_records=1"><B>|;
print chr($i);
print qq|</B></A></PRE></TD>\n|;
}

print qq|</TR></TABLE>|;

This will print a table, with each letter in its own cell, which will perform a search for records that begin with that letter or number. Be sure to change Name to match the name of the field in your database that you will be searching on.


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





Quote Reply
Re: 0-9 & A-Z Listing of Search Results - Any Ideas??? In reply to
Hi JPDeni,

Thanks for the code!

When I click on the "A-Z List" link from my main page, how do I call the code up that you gave me? Will I call it through the db.cgi? If yes, how would I do this?

Could I add new line in the db.cgi like:

elsif ($in{'a-z_search'})
{ if ($per_view) { &html_a-z_search; } else { &html_unauth; } }

Then make a new subroutine called html_a-z_search in the html.pl? Then would you call it like:

cgi-bin/db.cgi?a-z_search=1

Since anyone can view this there doesn't really need to be any kind of stiff authorization. I'm not sure if I'm on the right track or not.

One other question if I may? I have about 50 different items that each new company will add to our database. When they first type in the info it may be in a text field. But when someone does a search I would like to display a select box with a range of options in it like your example about doing a search on the Price of an item, which I have the code for. But thre are about 10 different fields in the database record like this that were text fields at first, but I would like all of them to be select boxes when the search page is called, using the -gt -lt idea for each one.

Can this be done? And how, if it's not too much trouble.

Everything is else is going well, and I'm just about finished. So I promise not to be asking too many more questions!

Thanks a million!!! Alex is very fortunate to have you and Eliot helping everyone like you do! I'll be glad to contribute to a support fund if there is such a thing. I really appreciate your time!

Cheers!

------------------
Chad Roadhouse
NitroMax Web Hosting
http://nitromax.com/index.html
Quote Reply
Re: 0-9 & A-Z Listing of Search Results - Any Ideas??? In reply to
Oh, I forgot one small thing.

I need the A-Z List to be pulled up in the spreadsheet format search results page. Not sure how to intergrate that.

Sorry!

------------------
Chad Roadhouse
NitroMax Web Hosting
http://nitromax.com/index.html
Quote Reply
Re: 0-9 & A-Z Listing of Search Results - Any Ideas??? In reply to
I took something for granted that I ought not to have done. I was assuming that you wanted the 0-9,A-Z list to print out from within DBMan. You want it on an html page?

If so, you'll need to create a link for each of the letters and numbers. For A, you would use

Code:
<a href="http://url/to/db.cgi?db=default&uid=default&Name=%5EA&view_records=1>A</a>

Repeat that for each letter and number, changing the A each time.

Wait a minute. I think I misunderstood again.

You want to have a separate link to pull up a page with the A-Z list? If so, you are on the right track. The only thing I would add (although you probably already know this) is the following to your link:

cgi-bin/db.cgi?db=default&uid=default&a-z_search=1

Otherwise, what you have written is perfect! Smile

The results will be returned in the "short" display, if there is more than one item returned. The "short/long" display mod is set up to use the short display if there is more than one record returned. Do you want to get the short display even if there's only one?

With your select box question, are these ranges? Or do you just want to make up a select field made up of the values of a field that exists in your database?

Thank you for your nice words. Smile The best contribution you can make is hanging around from time to time to help answer people's questions. Now that you're a pro, you shouldn't have any problem with that!! Smile


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





Quote Reply
Re: 0-9 & A-Z Listing of Search Results - Any Ideas??? In reply to
Hello,

I need the select boxes to be ranges, eventhough the data that was entered into the fields, when the record was added, was a singe number.

For example, 350 was entered into a text field but the select box would have a range of 300-500 to search... and so on.

I know from other examples you've given how to do this once, but how does the code look when doing it 10 times? I assume you just repeat the exact same thing below the first segment of code for each one? In another message you said:

---------------------------------------------
Right after

local (%sortby);

add code:
--------------------------------------------------------------------------------

$in{'Price_range'} = "100,000+";
$in{'Price_range'} =~ s/,//g;
$in{'Price_range'} =~ s/\+//g;
if ($in{'Price_range'}) {@Prices = split /-/, $in{'Price_range'};
$in{'Price-gt'} = int($Prices[0]) - 1;
if ($Prices[1]) {$in{'Price-lt'} = int($Prices[1]) + 1; }}

####################################
Do you just put another one here?
####################################

$in{'Webspace_range'} = "100,000+";
$in{'Webspace_range'} =~ s/,//g;
$in{'Webspace_range'} =~ s/\+//g;
if ($in{'Webspace_range'}) { @Webspaces= split /-/, $in{'Webspace_range'};
$in{'Webspaces-gt'} = int($Webspaces[0]) - 1;
if ($Webspaces[1]) {$in{'Webspaces-lt'} = int($Webspaces[1]) + 1; }}

#############################
Then another one???
#############################

--------------------------------------------------------------------------------

Is that what I would do?

Thanks again!


------------------
Chad Roadhouse
NitroMax Web Hosting
http://nitromax.com/index.html


[This message has been edited by Chad_R (edited September 28, 1999).]

[This message has been edited by Chad_R (edited September 28, 1999).]
Quote Reply
Re: 0-9 & A-Z Listing of Search Results - Any Ideas??? In reply to
Yep. That's what you need to do.

(People like you make it all worthwhile! Smile )



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