Gossamer Forum
Home : Products : DBMan : Customization :

Some Odd Questions :) Part 3!

(Page 1 of 2)
> >
Quote Reply
Some Odd Questions :) Part 3!
It happened! I was laying in bed and it hit me: the team roster pages!

I have little "areas"...30 of them in fact, on my site, one for each Major League Baseball team...and each of them contains a roster page which simply displays, in a table, their basic info, height, weight, salary, position, etc...with a link to their profile...no stats on the roster page, though...

Anyway, I was wondering if it was possible to have those pages be another DB...and basically print out all the members of that team in a table...it would judge which players are a member of the team by the "Team" field...which is a select box so there won't be any errors in spelling. Smile

I guess the way it would work is it would call upon the player data from the players.db file and then print out their info...is this tricky? If it is we needn't bother! Smile Just love posting any ideas I get...the cool thing about this is if I changed a player's team on his profile he'd automatically be switched to another team roster page! Ahhh, automation...

Chris

Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
This is a perfect example of the reason that relational databases are so cool. You can do stuff like this without much effort. Smile

The first thing you would want to do is to make sure that all the fields you want to display on the "team roster" page are within the "players" database. This might mean changing both the .cfg file and sub switch_to_players to account for extra fields, like salary. (You didn't have salary before, did you?)

You wouldn't need to create a separate .cfg file, because this would just be another type of search on the "players" database.

What might work -- and this is all off the top of my head Smile -- is to use a separate (abbreviated) html.pl file for the team roster. We'll call it "team_html.pl." You would only need the following subroutines:

sub html_record
sub html_view_success

Hmmm. I'm wondering if maybe you would like to have a "team.db" file. Is there information about the team that you would like to have -- for example, the name of their home field, the manager, owner, history -- anything like that? If so, then it would be best to create an entire database for the team, with the $db_key field to match the team name that is in the players db.

A lot depends on what you want to do. Smile


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






Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Wow! You're right, I could automate even more of all this stuff! This is amazing!

I'd probably have to create some more .db files...for managers and awards, like you said.

I won't have any problem adding the salary field...

I'll create the roster_html.pl file with the two subroutines like you mentioned...I'll see if I can figure out how to make it work on my own...if I can't figure something out i'll let you know.

Wish me luck!
Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Carol,

Now that I think about it I'm a bit confused...just to make sure we're talkin' bout the same thing, here's how the page would end up looking (for the most part):

http://www.warningtrack.net/...pirates/players.html

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Yep. That's exactly what I imagined it would be -- although you could have even more information in your "teams" database if you wanted to.

The players names would have links, just like in your page, which would bring up the stats that we worked on before.

Basically, you'll be doing for the players the same thing that you did with the stats.

Just be sure that your $db_key field matches the "team" field from the players db. For example, the key for the Pittsburgh Pirates would be "PIT."

Make sense?



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






Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Carol,

Still not sure what kind of commands I ought to use to pull out all players from a specific team.

I can't use the team abbrevation part because thats in the stats database...I would have to access the fields in the players.db file...where the team names are fully printed...IE: "Pittsburgh Pirates".

I've sort of started on the roster_html.pl file, but really don't know where to go, I'm SURE I've made mistakes, but don't really know what to do, I figured to print the records in the table the "foreach $rec" thing might work, but now I'm doubting my judgement! Smile

Here's my file so far:

http://www.warningtrack.net/roster_html_pl.txt

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
I guess I was thinking of the statistics files where you have the three-letter abbreviation.

Okay, then use the whole team name. That works just as well. Whatever can connect the team database to the players database.

The first thing you need to do is to set up your roster.cfg file with the fields for the team information.

I'm sorry. I was wrong before. I should have deleted what I had written.

You're going to need a whole html.pl file. (That's what I get for starting to write before I've finished thinking it through.)

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






Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
JP,

I think we're talking about something different now. I suppose I might eventually tinker around with DBMan to store team historical facts, award winners, etc, but I didn't know we were doing that now! I thought we were just setting up the automated roster pages, but heck, if you wanna setup the team database, its fine with me! Smile

I'm not sure what to put in the roster.cfg file...the Roster page will only be pulling info out of the players.cfg file and displaying a link to the whole profile in the players_html.pl file...so there isn't any need for any fields...

As for the team pages, thats a little complicated because the team pages would have several areas...they wouldn't just be on one page...like this (sort of):

http://www.warningtrack.net/teams/braves

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
And please don't apologize! Smile

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
FYI! Smile

I'm trying to setup the teams database on my own in a different directory. The main team page will have a link to the eventual roster page...but overall it should be able to remain seperate...

I'm still brainstorming about the roster page...I'll keep thinkin, and I'll try to setup the teams database (shouldn't be too tough, nothing relational or anything is involved!)

Chris! Smile
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
I'll tell you what. Later tonight (after the movie is over that I'm watching), I'll set up what I think would work really well and let you take a look at it. You can decide if that's what you want or not. Deal? Smile


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






Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Carol,

Sure! Whatever you want. I don't want to inconvienence you at all! I just want to make sure we're on the same wavelength. Smile

I might not be up late enough, but even then I'll have enough time tommorrow to check in now and then Smile

What movie ya watching? My family is made up of a bunch of movie nuts. Smile

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Hey, I was flipping in and out of Entrapment, too Smile

On HBO or something, right?

Take your time, there's no rush! Smile

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
We watched "Entrapment" with Sean Connery. Not bad. Good action. Hubby and I are big movie nuts, too.

In the back of my mind during the movie, I got some ideas. I haven't started as yet, but I'll have something for you tomorrow. (Probably. Smile )


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






Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Carol,

Just to clarify: should I keep working on the seperate-team page DB? Or did you have some plan mapped out for everything? I've you're just referring to the roster page let me know and I'll start my work on the team DB back up! Smile

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Every time I start to work on it, I am unsure of what to do.

It would be possible to put all of the information that is on your site into a multiple-table relational database -- teams, players, statistics, awards, managers, feats -- everything. It's a little complicated, but it could be done. I'm just not sure what you want to do.

The best way to build a database (especially a relational one) is to plan it out ahead of time. Going back and changing things after you've already written it is three times the work (at least) as doing it right the first time.

(Besides, I think I'm really tired tonight.)

I guess the question is, what do you want to do?


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






Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Carol,

Well, originally I just wanted to pull some of the info out of the players DB onto the roster page...but as you now mention it might make more sense to map this out in advance...

...ok, I'll describe it was best as I can...

I want a DB for the team pages (teams.cfg, teams.db)...each team page will have links to the roster and such...and maybe eventually it will pull some data out of the other DBs...I've got it setup now so I can have a team logo there...I just make a field called "team logo url", and reference that inside an </img> tag...

...so overall I think I can handle the teams database in terms of setup, etc...I'd imagine then I'd setup other DBs for each of the pages in each team area...a DB for the roster page, a DB for the general info page, etc.

I don't forsee any problems creating these myself...but what I need to do is learn how to pull info from other DBs onto these ones....just like pulling the info out of, say, the hitting DB, onto a record in the players DB...only instead of referencing a PlayerID field, we'd be referencing a team field for the Roster Page...

Overall I'm still working on the layout of the teams DB...it'll probably have like 20 fields, most of them URLs and such for images and team links...but all I think I need help with right now is pulling info from one DB to another. Smile

I'm assuming we'd add more switch_to subroutines, only a bit different so as to only print out certain fields? Smile

Hope this clear it up!
Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
That does help. Smile

In your "switch_to_*" subroutines, you must include every fieldname that is in the .cfg file for that database. You can choose which ones to print out, but every field must be accounted for or it won't work.

The problem I came up with is that teams have moved and have changed names over the years. It's not a problem for current players, but if you wanted to include world series stats and awards from before, it becomes a problem.

For example, the code for the Dodgers is "LOS" because they are in Los Angeles. But in the 50s, they were in Brooklyn, so the code was different. I'm not sure how to tell the script that it's the same team.

I could just use "Dodgers," which would take care of the above example, but a couple of teams have changed their names as well. Like the Texas Rangers were once the Washington Senators. (I've gotten most of this info from my hubby, who loves baseball statistics. Smile )

But -- this is your database and I should let you work on it yourself. Smile Let me know if you run into problems and I'll do my best to work them out with you.


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






Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Carol,

I see your point about the past awards and such...that could present a problem...but if it all comes down to it I can just setup a totally seperate database for some of these things, like past award winners or records, etc...

...my only concern now is pulling player info onto other DBs, like the roster page, etc.

I have the subroutines before, but what kind of code should I use in the html.pl file? I have the code from before but if I remember correctly it contained a command to print out all the fields...but in this case I only want to print certain ones...

...and I still really have no idea what kind of command to use to pull all of the, say "Pittsburgh Pirates" listed in the DB onto the roster page...! Smile I was thinking and if/foreach command, or something, but I'm still getting used to Perl. Smile

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
To print out certain fields from the players database, use the format of $rec2{'FieldName'} for each field that you want to print out.

To get the players from a given team, there needs to be some way to tell the script what team you're wanting. I'm not sure how you want to do that.

Once you get the team established, use

Code:
undef %in;
&switch_to_players;
$in{'TeamID'} = the variable that holds the team name;
$in{'sb'} = 6; # Change to the number of the field you want to sort by
$in{'mh'} = 100; #To make sure you get them all
my ($status2,@hits2) = &query{"view");
if ($status2 eq "ok") {
my ($numhits2) = ($#hits2+1) / ($#db_cols+1);
print "<table>";
for (0 .. $numhits2 - 1) {
%rec2 = &array_to_hash($_, @hits2);
print out the fields you want from the players database using $rec2{'FieldName'} for the data
}
print "</table>";
}


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






Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Carol,

I gave it a try...but not luck! Here's the code I added to sub_html_record_long in the rosters_html.pl file...

Code:
undef %in;
&switch_to_players;
$in{'Team'} = Pittsburgh Pirates;
$in{'sb'} = 2; # Change to the number of the field you want to sort by
$in{'mh'} = 100; # To make sure you get them all
my ($status2,@hits2) = &query{"view");
if ($status2 eq "ok") {
my ($numhits2) = ($#hits2+1) / ($#db_cols+1);
print "<table>";
for (0 .. $numhits2 - 1) {
%rec2 = &array_to_hash($_, @hits2);
$rec2{'Last'}, $rec2{'First'} - $rec2{'Team'}
}
print "</table>";
}

Here's the URL if you wanna check it out...it's got the same data and cfg file as the players DB...is that the problem? (ID/Pass: admin/admin):

http://www.warningtrack.net/...ts/db.cgi?db=rosters

Chris! Smile
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Carol,

My bad, I fixed that problem, but get a CGI error...not sure what to do...but I'll mull it over for a bit! Smile

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Carol,

Made the change, but got the same error! Still says it's can access the subroutine...

Chris
Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Two things.

First update the html.pl file that I can look at.

Second let me know where I can see this.

I don't know what's wrong.


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






Quote Reply
Re: Some Odd Questions :) Part 3! In reply to
Lois,

You're right, that was a mistake of mine! I've fixed it, but still get this error message (same one I got before):

Code:
CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: syntax error at ./rosters_html.pl line 555, near ""view")"
Missing right bracket at ./rosters_html.pl line 1590, at end of line

I checked out the html it was referring to and I'm not sure what to do! Smile

Chris
> >