Gossamer Forum
Home : Products : DBMan : Customization :

list of field

(Page 1 of 3)
> >
Quote Reply
list of field
Hi,
i would to make a html list (with html links)
with the content of a field.
How can i do this thing

stéphane
Quote Reply
Re: list of field In reply to
Would you like to have what I have on my Employee Directory database?

Here is an example:

http://www.coco.cc.az.us/...lt&browse_area=1

If so, I can post the codes that you can use to do this.

Let me know.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: list of field In reply to
Re,
thanks ! can you send me your codes ?

bye

Stéphane


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

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706
Quote Reply
Re: list of field In reply to
These codes are for creating a separate page in the DBMAN system that will list the number of records in a certain field within the database.

1) In your db.cgi file, add these codes to the list of elsif statments in the sub main routine:

Code:
elsif ($in{'browse_cat'}) { if ($per_view) { &html_browse_cat; } else { &html_unauth; } }

2) In your html.pl file, create a new sub-routine towards the bottom of the file. Name this sub-routine, sub html_browse_cat:

Code:
sub html_browse_cat {
# --------------------------------------------------------
# Browse Academic Areas

for ($i = 0; $i <= $#db_cols; $i++) {
if ($db_cols[$i] eq "FieldName") {
$fieldnum = $i; $found = 1;
last;
}
}
if (!$found) {
&cgierr("No Area field defined");
}
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 (!(grep $_ eq $fields[$fieldnum], @selectfields)) {
push (@selectfields, $fields[$fieldnum]);
}
++$count{$fields[$fieldnum]};
}

close DB;

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Browse Categories</title>
</head>

<body bgcolor="#FFFFFF">

|; &html_top_header; print qq|

<center>
<table bgcolor="#FFFFFF" cellpadding=2 cellspacing=0 width=600 align=center valign=top>
<tr><td>

<$font_title>
<b><A HREF="$db_script_link_url">$html_title</a> : Browse Categories</b>
</font>
<p>
<$font>
INSERT TEXT
<p>
|;
foreach $field (sort @selectfields) {
if ($sfield eq "") {
print qq| |;
}
if ($sfield = &urlencode($field)) {
print qq|<$font><a href="$db_script_link_url&view_records=1&ID=*&Area=$sfield">
$field</a>:</font> <$smfont>(<font color="ff0000">$count{$field}</font> )</font><BR>|;
}
}
&html_footer;
print qq|
</td></tr>
</table>
|; &html_bottom_footer; print qq|
</center>
</body>
</html>
|;
}

Replace the FieldName with the field name in your default.cfg file that you want to obtain a listing from. Also, in the link for the this mod, you may need to additional attributes, such as so and sb. Where it states INSERT TEXT, you will have to put your own text.

3) Then in your sub html_home routine, add the following link:

Code:
<A HREF="$db_script_link_url&browse_cat=1">Browse Category</a>

Hope this makes sense and works for ya.

Smile

Regards,


------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 10, 1999).]
Quote Reply
Re: list of field In reply to
Re,
great :-)
thanks :-))))))))
Quote Reply
Re: list of field In reply to
You're welcome.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: list of field In reply to
re,
there are errors :

Message : fatal error: Undefined subroutine &main::urlencode called at ./rasom.pl line 1445.

???

Stephane

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

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706
Quote Reply
Re: list of field In reply to
DID you add the following codes to your sub main routine in your db.cgi file?

Code:
elsif ($in{'browse_cat'}) { if ($per_view) { &html_browse_cat; } else { &html_unauth; } }

Also make sure that you have the following sub-routine in your db.cgi file:

Code:
sub urlencode {
# --------------------------------------------------------
my($toencode) = @_;
$toencode=~s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$toencode=~s/\%2F/\//g;
return $toencode;
}

This can be placed towards the bottom of the db.cgi file.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 10, 1999).]
Quote Reply
Re: list of field In reply to
Yes,

----------------------------
sub main {
# --------------------------------------------------------
my ($status, $uid);
local($per_add, $per_view, $per_mod, $per_del, $per_admin);

$|++; # Flush Output Right Away

&auth_cleanup unless ($auth_no_authentication); # Remove old session files.

($status, $uid, $per_view, $per_add, $per_del, $per_mod, $per_admin)
= &auth_check_password; # Authenticate User, get permissions and userid.

if ($status eq "ok") {
# Set the script link URL with db and user info for links. Use $db_script_url for forms.
$db_script_link_url = "$db_script_url?db=$db_setup&uid=$db_uid";
($db_userid) = $db_uid =~ /([A-Za-z]+)\d+/;

# Main Menu. Check to see what the user requested, then, if he has permission for that
# request, do it. Otherwise send the user off to an unauthorized request page.
if ($in{'add_form'}) { if ($per_add) { &html_add_form; } else { &html_unauth; } }
elsif ($in{'add_record'}) { if ($per_add) { &add_record; } else { &html_unauth; } }
elsif ($in{'view_search'}) { if ($per_view) { &html_view_search; } else { &html_unauth; } }
elsif ($in{'view_records'}) { if ($per_view) { &view_records; } else { &html_unauth; } }
elsif ($in{'delete_search'}) { if ($per_del) { &html_delete_search; } else { &html_unauth; } }
elsif ($in{'delete_form'}) { if ($per_del) { &html_delete_form; } else { &html_unauth; } }
elsif ($in{'delete_records'}) { if ($per_del) { &delete_records; } else { &html_unauth; } }
elsif ($in{'modify_search'}) { if ($per_mod) { &html_modify_search; } else { &html_unauth; } }
elsif ($in{'modify_form'}) { if ($per_mod) { &html_modify_form; } else { &html_unauth; } }
elsif ($in{'modify_form_record'}) { if ($per_mod) { &html_modify_form_record; } else { &html_unauth; } }
elsif ($in{'modify_record'}) { if ($per_mod) { &modify_record; } else { &html_unauth; } }
elsif ($in{'admin_display'}) { if ($per_admin) { &admin_display; } else { &html_unauth; } }
elsif ($in{'browse_cat'}) { if ($per_view) { &html_browse_cat; } else { &html_unauth; } }
elsif ($in{'logoff'}) { &auth_logging('logged off') if ($auth_logging);
$auth_logoff ? (print "Location: $auth_logoff\n\n") : (print "Location: $db_script_url\n\n"); }
elsif ((keys(%in) <= 2) &#0124; &#0124;
($in{'login'})) { &html_home; }
else { &html_unkown_action; }
}
# If we allow users to signup, and they want to, go to the signup form.
elsif ($auth_signup and $in{'signup_form'}) {
&html_signup_form;
}
elsif ($auth_signup and $in{'signup'}) {
&signup;
}
# Auth Check Password has determined that the user has not logged in, so let's send
# him to the login screen.
elsif ($status eq "no login") {
&html_login_form;
}
# Auth Check Password had an error trying to authenticate the user. Probably there was
# an invalid user/password or the user file has expired. Let's go to an error page and
# ask the user to re log on.
else {
&html_login_failure($status);
}
}
------------------------------

What the problems ?????

Stéphane

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

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706
Quote Reply
Re: list of field In reply to
Like I mentioned:

If you do not have the following sub-routine in your db.cgi file, then add it:

Code:
sub urlencode {
# --------------------------------------------------------
my($toencode) = @_;
$toencode=~s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$toencode=~s/\%2F/\//g;
return $toencode;
}

Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: list of field In reply to
In the URI string, you also have to add sort by field, like sb=1.

So, the link should look like: (Yes, try adding the codes with the browse_cat=1 URL.)

Code:
<a href="$db_script_link_url&browse_cat=1&sb=number&so=descend">

Replace number with the number of your Year Graduated field.

See if that works.

Remember that anytime you want to create a list from a string of parameters, you have to specify the number of field (sort by) in order to activate the descending order.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: list of field In reply to
Eliot - I have added this as an add-on for the admin to see what the total records are for the current year graduated field.

However, I tried to add so=descend and it doesn't seem to work.

Any ideas?

Here's the link that should make this work:

if ($per_admin) {
print qq|
Find who the top 5 classes are: <A HREF="$db_script_link_url&browse_cat=1&so=descend">Browse Category</a><br><br>|;
}
Quote Reply
Re: list of field In reply to
Take out the sort by statment (so=descend).
The link for the browse_cat routine takes the user to that sub-routine. DO NOT add in any other var attribute to the URL string, such a so.

It should work with the instructions I gave you.

If you want the list to sort by descending order, then you would add so=descend to the links created on the browse category page!

Like the following codes:

Code:
<a href="$db_script_link_url&view_records=1&ID=*&Fieldname=$sfield&so=descend">

Also you need to change the Area[ field in the URI. Sorry I forgot to change that. Area should be the fieldname that you are trying to list.

Does this make sense?

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: list of field In reply to
Eliot - I forgot to edit my earlier message - I had already figured out that had the so=descend in the wrong place. I have since corrected that.

I still cannot get the categories to display in descending order.

I am trying to get our to display this way:

1979: (64)
1978: (59)
1977: (49)
1964: (41)
1966: (41)

The year is the "Year Graduated" field. I want them to display in descending order according number of records in each year (highest number of records first and then descending from there).

I hope you understand what it is that I trying to accomplish and lead me in the right direction to accomplishing this.

Thanks!
-----------------
donm
Quote Reply
Re: list of field In reply to
Eliot - still not working. Here is the code that I have in place.

In sub html_browse_cat I have:
if ($sfield = &urlencode($field)) {
print qq|<$font><a href="$db_script_link_url&view_records=1&ID=*&Year Graduated=$sfield">
$field</a>:</font>
<$smfont>(<font color="ff0000">$count{$field}</font> )</font><BR>|;
}

In sub html_home I have:

if ($per_admin) {
print qq|
Find who the top 5 classes are: <A HREF="$db_script_link_url&browse_cat=1&sb=5&so=descend">Browse Category</a><br><br>|;
}

"5" is the field number in default.cfg for the 'Year Graduated' field.

-----------------
donm
Quote Reply
Re: list of field In reply to
One problem that I have come accross with this particular mod is that field names with spaces (even with '' attached to them in the default.cfg file) do not list properly. Try changing the 'Year Graduated' to Year_Graduated in default.cfg. Then change the codes for the browse category routine.
If that works, then you will have to change Year Graduated to Year_Graduated in all routines where you have Year Graduated.

Let's see if that works.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 12, 1999).]
Quote Reply
Re: list of field In reply to
Nope - still no go. Changed all instances of Year Graduated to Year_Graduated

--------------
donm
Quote Reply
Re: list of field In reply to
donm,

Let me clarify your problem...You are able to get a list of values for the field, but it does not show up in the correct order, right?

I really don't know what to tell ya. The problem may be related to the fact that you are trying to list a numerical field in descending order. Carol may have to assist you at this point.

Stephane,

I don't understand your post. Please be more clear!

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: list of field In reply to
Eliot - you are correct I do get a list of values for the field but I cannot get them to display in descending order.

-----------------
donm
Quote Reply
Re: list of field In reply to
Okay...try this...I don't gaurantee it will work, but give it a shot:

Replace the following line:

Code:
for ($i = 0; $i <= $#db_cols; $i++) {

with the following:

Code:
for ($i = 0; $i => $#db_cols; $i++) {

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: list of field In reply to
Hello / Bonjour,
All is right now for me :-) But DBMAN can't create "indexes" like ISIS ???

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

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706
Quote Reply
Re: list of field In reply to
No - still the same no change.

-------------
donm
Quote Reply
Re: list of field In reply to
Welp, Since Carol wrote the codes. She will have to be the one to help you.

I have done EVERYHING that I can. Sorry it does not ideally work for you.

Smile

Sorry.

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: list of field In reply to
Eliot - no problem. I appreciate the help. It works for what I need right now. Ideally I would like for it to display in descending order.

But I can wait until Carol gets well.

Thanks again !
---------------
donm
Quote Reply
Re: list of field In reply to
Hello / Bonjour,

Can one manufacture indices (index in french) with DBMAN ? Several software it does (like Isis).

Best

Stéphane





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

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706

[This message has been edited by Stephane (edited September 13, 1999).]
> >