Gossamer Forum
Home : Products : DBMan : Customization :

list all on log on

Quote Reply
list all on log on
Does anybody know of a way to automatically list all records when a users logs on?


:water
Quote Reply
Re: list all on log on In reply to
At the beginning of sub html_home, you could add

Code:

$in{$db_key} = "*";
&view_records;
return;


JPD
Quote Reply
Re: list all on log on In reply to
What about if you have a group of registered users that are identified by year (i.e. 1985) and whenever they login you would like for it to skip the home_html and instead list all records for the year of the person logging in - if the person logging in has no record (year) it defaults to the home_html - can this be done?

----------------
donm

Quote Reply
Re: list all on log on In reply to
Hello, Don. Smile

I guess you could do that.

You would need to first get the record for the user, if one exists. Then you would need to pull out the year from the user's record. Then you would set $in{'Year'} (or whatever your field is called) to that year. Finally, you would do the search.


JPD
Quote Reply
Re: list all on log on In reply to
Carol - I know you are very busy and I don't want to you to go looking for this - but just off the top of your head can you think of any mod or anything else where I might be able to find an example of what you describe in your post?

As always thanks for your help!
--------------------------------
donm

Quote Reply
Re: list all on log on In reply to
This isn't a really big thing actually. Or at least I don't think it is. What I'm going to give you depends on having the userid field as the $db_key field. If you don't, it'll take a little more work.

Here's what to add to sub html_home:

Code:

$rec_user=&get_record($db_userid);
if ($rec_user{$db_key}) {
$in{'Year'} = $rec_user{'Year'};
$in{'sb'} = the number of the field you want to sort by;
&view_records;
return;
}
Change Year to the name of your year field.



JPD
Quote Reply
Re: list all on log on In reply to
Wouldn't you know it - I am not using the userid as the db_key. I have two fields userid which the user enters upon signup and "id" which is assigned by the counter to insure unique user/member.

The db_key is set to "id"

---------------------
donm

Quote Reply
Re: list all on log on In reply to
Well, it's a little more complicated then.

Code:

$in{$db_cols[$auth_user_field]} = $db_userid;
my ($status,@hits) = &query("view");
if ($status eq 'ok') {
undef %in;
%rec_user = &array_to_hash(0, @hits);
$in{'Year'} = $rec_user{'Year'};
$in{'sb'} = the number of the field you want to sort by;
&view_records;
return;
}
JPD
Quote Reply
Re: list all on log on In reply to
Well, I tried that and it worked great except at the top of the pages whenever there are more than 25 hits returned.

You get the "Pages - 1 2 3 4 >>" If you try and go to the next pages - you are brought tp the "login" screen.

What would make it do that?
--------------------------
donm

Quote Reply
Re: list all on log on In reply to
Forgot something. Blush

After undef %in; add

$in{'view_records'} = 1;

That should fix it.

But maybe not.

If that doesn't work, try adding

$ENV{'QUERY_STRING'} = "db=$db_setup&uid=$db_uid&Year=$rec_user{'Year'}&view_records=1";

I'm not sure if that will work either, but it might. And it's the only other thing I can think of. Smile



JPD
Quote Reply
Re: list all on log on In reply to
Nope - tried that and still no go. Same results.

-----------------
donm

Quote Reply
Re: list all on log on In reply to
I'm not sure what to tell you, then.

The links from one page to the next depend on the $ENV{'QUERY_STRING'}, which is the part of the URL after the ?. I was thinking that you fool the script into thinking the values came through the URL by setting the $ENV{'QUERY_STRING'}. I guess not.

You could set it up so that all of the records display on one page so that it wouldn't have any page links.


JPD
Quote Reply
Re: list all on log on In reply to
It's ok - I would have liked to get this working but it's not absolutely necessary.

Thanks for your help.
--------------------
donm

Quote Reply
Re: list all on log on In reply to
Carol - I tried the following code again:

$ENV{'QUERY_STRING'} = "db=$db_setup&uid=$db_uid&Year_Graduated=$rec_user{'Year_Graduated'}&view_records=1";

and this time I get the following error:
"no search terms specified"

We might be getting closer?
---------------------------
donm

Quote Reply
Re: list all on log on In reply to
Might be.

I had another idea, though.

Code:

$in{$db_cols[$auth_user_field]} = $db_userid;
my ($status,@hits) = &query("view");
if ($status eq 'ok') {
%rec_user = &array_to_hash(0, @hits);
print "Location: $db_script_link_url&Year_Graduated=$rec_user{'Year_Graduated'}&view_records=1\n\n"
}
If you still get a "no search terms" message, we'll have to take a look at the %rec_user hash to see what's up.


JPD
Quote Reply
Re: list all on log on In reply to
I am not real sure what should have been returned - but when I logged in this was at the top of home_html:

Location: http://cocoahighalumni.com/cgi-bin/alumni/db.cgi?db=default&uid=donm77.96101742392589&Year_Graduated=1977&view_records=1

-------------------
donm

Quote Reply
Re: list all on log on In reply to
You need to put the code before the line

&html_print_headers;

The code must be the very first thing in sub html_home.


JPD
Quote Reply
Re: list all on log on In reply to
Carol - That worked great !!

Thanks for your help as always !

-----------------
donm