Gossamer Forum
Home : Products : Gossamer Links : Discussions :

New Column As A Search By In Search Form

Quote Reply
New Column As A Search By In Search Form
Hi.

I have added a column 'City' in Links table
How can i get the drop down list of "distinct" cities in the Search Form so that even 'City' could be used for filtering (restricting) the search results to....

TIA
Anup
Quote Reply
Re: [anup123] New Column As A Search By In Search Form In reply to
Try something like;

<%new_global_name%>

Code:
sub {

my $back = q|<select size="1" name="City">|;
$back .= qq|<option value="">All</option>|;

my $table = $DB->table('Links');
$table->select_options('ORDER BY City ASC');
my $sth = $table->select( 'DISTINCT(City)' ) || die $GT::SQL::error;
while (my $hit = $sth->fetchrow_hashref) {
$back .= qq|<option>$hit->{City}</option>|;
}

$back .= q|</select>|;

return $back;
}

Untested, but sticking this new global on your search template should let you show a list of unique Cities.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Apr 19, 2004, 1:20 AM
Quote Reply
Re: [Andy] New Column As A Search By In Search Form In reply to
Hi Andy.

Tried and got error:

Global symbol "$sth" requires explicit package name at (eval 1657) line 4

Also, along with the City I would also need the Option "All"
Just like the drop down of Top Category in Search form (A Global By Alex).

Thanks
Anup
Quote Reply
Re: [anup123] New Column As A Search By In Search Form In reply to
Hi. Please try the modified one (in my above post).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] New Column As A Search By In Search Form In reply to
Hi.

Perfect 10!

Though not immediate, but an extension to the same (possibly to make it complete):

A Similar Drop Down For Country (With Option All included) ... I am sure that your code could be duplicated for Country.

Now the addendum to the above:

If a user does not specify Country, then the "City" Drop Down in Not Available and the complete database is searched depending upon the other criteria.

If a user specifies a Country from the Drop Down, then:

The "City" Drop Down becomes visible on the Search Form where a user can Select a specific City (pulled from DB for the COuntry Selected as in yr code) or leave as "All".

Thanks once again.

Anup

Last edited by:

anup123: Apr 17, 2004, 7:15 AM
Quote Reply
Re: [Andy] New Column As A Search By In Search Form In reply to
Hi Andy

Want to add ORDER By City ASC

What and where to modify?

Thanks
Anup
Quote Reply
Re: [anup123] New Column As A Search By In Search Form In reply to
Seems he modified the post, but didn't post he modified it :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] New Column As A Search By In Search Form In reply to
Ooops... thats what happens when you work early hours of the day Tongue

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] New Column As A Search By In Search Form In reply to
Thanks Andy.

Anup