Gossamer Forum
Home : Products : DBMan : Customization :

List Categories and Give a Count mod

Quote Reply
List Categories and Give a Count mod
does anyone know of a way to return the count on just one item from a catagory....like "blue" in the color catagory....and do it from the address line of the browser....I've tried the various sub mods...there are eight....and none of them are right....they give you the break down of an entire catagory...3 blue 2 red 1 orange....and the criteria is hard coded in the html.pl file...I want to be able to search a given catagory for just one item...and have dbman return a link and a count...23 blue....and I need to do this from the address line of a browser....for various reasons...thanks guys

ps. I notice that when you do a search it tells you how many hits you got....I could use that...delete the actual results from sub html_record, that would be great, but I'd need a link to the actual results..
Quote Reply
Re: [steven99] List Categories and Give a Count mod In reply to
okay, after snooping around all morning I've found what I need......

I can achieve what I want by having the mod also check the user name and only display the catagory and count for the current user.....and I found the mod's mod to do that......I thought I was on easy street, except that the mod has been changed....here was the old solution

###########################

Re: List Categories and Give a Count [In reply to] Quote | Reply

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

There are two sets of codes in the mod, one for pulling the category names from a select field, and one for pulling them from the database. You would want to use the second set of codes. (Also, be sure to add sub urlencode to your db.cgi file, which is at the beginning of the mod file.)

To only count the records which belong to one user, you can work with the following section:


--------------------------------------------------------------------------------
Code
--------------------------------------------------------------------------------

#### if you are using the validate records mod, uncomment the following line and replace the "4" with the #### number of your Validated field # if ($field[4] eq "Yes") { ++$count{$fields[$i]}; if (!(grep $_ eq $fields[$fieldnum], @selectfields)) { push (@selectfields, $fields[$fieldnum]); } #### if you are using the validate records mod, uncomment the following line # }

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


You would change it to


--------------------------------------------------------------------------------
Code
--------------------------------------------------------------------------------

if ($field[$auth_user_field] eq $db_userid) { ++$count{$fields[$i]}; if (!(grep $_ eq $fields[$fieldnum], @selectfields)) { push (@selectfields, $fields[$fieldnum]); } }

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


Also, remember to change


--------------------------------------------------------------------------------
Code
--------------------------------------------------------------------------------

if ($db_cols[$i] eq "Category" ) {

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


to match the name of your city field.

Be sure to read the other notes within the mod carefully.


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


####################################

I can't find the above code in and of the mod variations now listed, and I believe the mod has been redone?

Even though I see how the user id is checked I can't seem to get it to work if I try and use it in the new mod version....jpd, you out there?
Quote Reply
Re: [steven99] List Categories and Give a Count mod In reply to
The following thread may help:

Thread: http://gossamer-threads.com/p/000661
Subject: Counter for different TYPE
nels - 7-Aug-99

This is also listed in the FAQ noted below under "Counts" as "Counter for different TYPE"

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/