Gossamer Forum
Home : Products : DBMan : Installation :

Pre-defined Search Link

Quote Reply
Pre-defined Search Link
I'd like to make this link work link with the userid of the logged in user (not the record owner). If I leave out the $rec{'Userid'} than I get Class1 match of all Userid's.

Permissions are:
There is authentication and no default user allowed.auth_modify_own=0 and auth_view_own=0
auth user field 9

<A HREF="$db_script_link_url&Userid=$rec{'Userid'}&ID=*&Class1=period1&sb=ID&modify_form=1">
1st Period</A>

( Where I'm heading is that I'd like to be able to use a new variable from an array for the Class1 field, but I'm taking it one step at a time)

Thanks
Fred
Quote Reply
Re: Pre-defined Search Link In reply to
I'm not sure I understand.

The userid of the logged in user is held in a variable called $db_userid. If you used the following:

$db_script_link_url&Userid=$db_userid&...

You will get records that belong to the logged in user. Is that what you want?

BTW, there's a problem with
sb=ID

If you want to sort by a field, you need to have the number of the field listed, not the name.



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





Quote Reply
Re: Pre-defined Search Link In reply to
Thanks -$db_userid is just the ticket for me.

The ultimate design will have a series of field pairs(triplets actually) consisying of name1,class1,comment1.....name6,class6,comment6. Some of the records in each name? field will be a match for the current user ($db_userid), so that the search string will only show those records. Could you think (ponder) and let me know about:

1) How can I create a variable = data from Class1 in thefirst record with $db_userid match to name1?

2) Also, I would like to be able to create another variable to use in printing forms so that the field which is edited is Comment1, if Class and Name are 1; Comment2 if Name2 etc.

and a quickie
3) In my search, is &modify_form=Search the same as &modify_form=1

Thanks
Fred
4AM?



&modify_form=1
Quote Reply
Re: Pre-defined Search Link In reply to
 
Quote:
How can I create a variable = data from Class1 in the first record with $db_userid match to name1?

Can you give me an example record and an example of a search? I must still be asleep. Smile

Quote:
Also, I would like to be able to create another variable to use in printing forms so that the field which is edited is Comment1, if Class and Name are 1; Comment2 if Name2 etc.

I really think I need to go back to bed! Smile I'm going to require an example of this, too.

Quote:
In my search, is &modify_form=Search the same as &modify_form=1

A question I can answer! Yay!!! Yes. Smile You can use the "&modify_form=1" format in links to make them shorter.

JPD

Quote:
4AM?

Yeah, I got to working on programming and couldn't stop until I'd worked out a problem.

Quote:
&modify_form=1
Wink

Quote Reply
Re: Pre-defined Search Link In reply to
You're fine, I'm confused.

1)how do I get "Intro to Perl" into $class1variable, which I can use in the search link, and to name the search link.
(there would be links for as many classes as the instructor has)
And

2) after Fred clicks on the search link named $class1variable, and selects a record to edit, that record contains the field comments1. The comment field numbers match the name and class field number.

Thanks,
Fred

Up to 4AM programming? You're breaking my heart JPD!



[This message has been edited by FMNewman (edited June 03, 1999).]
Quote Reply
Re: Pre-defined Search Link In reply to
So you need to get a list of all of FRED's courses and you want a link for each one which will do a search and result in the list of students that enrolled in that class, which he can then modify.

I'm not sure where this would go. It would be somewhere in html.pl, but I'm not sure about where you want the list of classes to appear. I guess we can work that out later.

So what we need to do is to search through the records, find every one with FRED as the instructor, pull out the course names, but only have each name listed once. (It helps if I define the problem first. Smile )

Code:
$teacher_fieldnum = 2; # Change this to match the number of the field where the teacher's id is
$class_fieldnum = 3; # Change this to match the number of the field where the class name is

open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name.
Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if ($fields[$teacher_fieldnum] eq $db_userid) {
if (!(grep $_ eq $fields[$class_fieldnum], @classes)) {
push (@classes, $fields[$class_fieldnum]);
}
}
}
close DB;

At this point, the classes for the logged in user are in an array called @classes.

To print out the class names, use

Code:
foreach $class (@classes) {
print qq|$class<BR>|;
}

Of course, that doesn't get you your link, but I think we should test this to see if it works before we go any further.


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





Quote Reply
Re: Pre-defined Search Link In reply to
Hi
I tried the code-thanks.
Depending on where I put it, I get different results.
Best place is, I think, at the end of sub html_record.

Printing, I can't seem to get. Best results, (not good results) were adding the printing to the short record display. I got strange things. I tried adding $class to the short record table, but that didn't go either.
There should be two identical matches(they would always be identical) in the @class, but sometimes it printed 12, or 20. A couple of times I got it print 2, but not where it should have been.

Any thoughts about placing the code or printing in the short display?
print qq|
<td>$rec{'Userid'}</td>
<td>$rec{'Class1'}</td>
<td>$class</td>
|;

Thanks
Fred
Quote Reply
Re: Pre-defined Search Link In reply to
At what point do you want this list to print out?


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





Quote Reply
Re: Pre-defined Search Link In reply to
G'Day -

The reason I wanted to be able to print the array to a form is to check what it contained.

I really need to print one element ($class perhaps?)of the array, since they should all be identical!

In the short display, This will be the name of the class.

In the search link (if $class is the variable from the array of matching classes in column 3)
<A HREF="$db_script_link_url&name1=$db_userid&ID=*&class1=$class&sb=ID&modify_form=1">
"$class"</A>

I would click on a link that is the actual name of the class from column 3, and perform a search to match that class name in column 3 AND $db_userid with the intructor name in column 2.

I tried $classes[0] that seems OK for the short display, but the search is wrong, and the only the "" appears

<AHREF="$db_script_link_url&Userid=$db_userid&ID=*&Class1=$classes[0]&sb=0&modify_form=1">"$classes[0]"</A>

Thanks
Fred

Quote Reply
Re: Pre-defined Search Link In reply to
Continued in your new thread.

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