Gossamer Forum
Home : Products : DBMan : Customization :

Some Odd Questions :) Part 4!

(Page 2 of 2)
> >
Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Carol,

It's tricky to post a record...I listed all the form fields just a few posts back as well as links to some records:

http://gossamer-threads.com/perl/forum/showthreaded.pl?Cat=&Board=DBCust&Number=83567&page=&view=&sb=&vc=1#Post83567

This should give you what you need: go here and login with admin/admin, you can then see it as I have :) hehe.

And no problem on the delay...you know you're doing all of us favors, take your time! :)

http://www.warningtrack.net/cgi-bin/stats/db.cgi?db=players

Thanks,
Chris



Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
What I was trying to do was to give you a roster that looked like the one at http://www.warningtrack.net/.../redsox/players.html. However, without a database for the team info, you won't be able to include the manager's name. Also, since you don't have a field in the players database for salary, you won't be able to include that either.

Anyway, here's what I have. Put the following in your player html.pl file:

Code:

sub html_roster {
#------------------------------------

$in{'mh'} = 100;
$in{'sb'} = 3;
my ($status,@hits) = &query("view");

my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

print qq|your top of page formatting|;

print qq|
<table><tr><td>&nbsp;</td>
<td align=right><B>$in{'Team'}</B></td></tr></table>
<table border="0" cellspacing="0" width="417">
<tr bgcolor="#215295"><td><font color="#ffffff">Pos</font></td>
<td><font color="#ffffff">Player</font></td>
<td><font color="#ffffff">Ht.</font></td>
<td><font color="#ffffff">Wt.</font></td>
<td><font color="#ffffff">Birthdate</font></td></tr>|;

for (0 .. $numhits - 1) {
%rec = &array_to_hash($_, @hits);
print qq|<tr bgcolor="#ffffff">
<td>$rec{'Position'}</td>
<td><a href="$db_script_link_url&$db_key=$rec{$db_key}&ww=1&view_records=1">$rec{'Last'}, $rec{'First'}</a></td>
<td>$rec{'Height'}></td>
<td>$rec{'Weight'}></td>
<td>$rec{'Birthdate'}</td></tr>|;
}

print qq|bottom of page formatting|;
}
In db.cgi, sub main add

elsif ($in{'roster'}) { if ($per_view) { &html_view_roster; } else { &html_unauth; } }

Make sure that your links to the roster include &roster=1 and the name of the team. Don't forget to replace any spaces with + signs -- Boston+Red+Sox.


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

Giving it a try right now, I'll let you know how it goes! If it all works okay I'll probably move on and add the salary fields myself...is it the same as if I just wanted to add them with any other copy of DBMan? Don't worry, I'll backup whatever I do!

Thanks so much! I'll letcha know how it goes!

Chris

Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Sorry JP, I got an Internal Server Error. The problem was with the db.cgi file...where does this line go, specifically? Being it's own elsif command I imagine it might not "fit" everywhere:

elsif ($in{'roster'}) { if ($per_view) { &html_view_roster; } else { &html_unauth; } }

The other file is fine, uploading the subroutine produced no error, but no noticeable effect. :)

Chris

Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Put that line in amongst all the other elsif commands in your sub main. The other ones will be in the same format.

rog

Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Thanks! Error is gone!

However, I go to this URL, and it produces a blank roster page without any players inside:

http://www.warningtrack.net/cgi-bin/stats/db.cgi?db=players&uid=default&roster=2

And yeah, I'm sure there are players who's "RosterID" field has a "2" in it...two of them...on the Arizona Diamondbacks.

Chris

Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Two things -- one is my fault.

Before the line

print qq|bottom of page formatting|;

you need to close off your table tag

Code:

priint "</table>";
The other is that there is no place that the RosterID is used.

Make sure that your links to the roster include &roster=1 and the name of the team.

Your link should look like

...db.cgi?db=players&uid=default&roster=1&Team=Boston+Red+Sox


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

I sent you a message from your contact form on JPDeni.com...did you get it? If not please email me: chris@warningtrack.net - I'd like to thank you for all your incredible work. :)



Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Hi again! Database has been working great, but I have found one flaw that's thrown it a bit out of wack...

As you know, each player record looks up that player's PlayerID (the primary key for the players DB) and then matches that ID up with any records found in the hitting or pitching databases...and then displays them as statistics on the player's page.

The problem I've found is that the player with, say...the PlayerID of "2" has his stats displayed, as well as the player with the PlayerID of "12"...as in if I ever created a record with the ID of "200", those stats would be displayed on the "2" page as well...

Is there a way to fix this? :)

Thanks!

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

In the link to the player stats, add &ww=1. That should fix the problem.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
I'm not sure how exactly...I tried simply changing the link on the sub html_record file (the link to the long display), but it didn't work...

Good to see you again! I just *CANNOT* get over how cool this database is...amazing that Perl can do this...

I hope Alex is well-versed in PHP though...it's definetly the up and coming language, and I'd love to see Gossamer-Threads improve their scripts with it!


Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
I think I'm going to need a refresher on the databases you have. What is the database where you are before you go to the stats page?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Um...I don't follow! Don't know if this helps, but you can take a little looksy at the DB if you like...

http://www.warningtrack.net/cgi-bin/database/players.cgi?db=players&uid=default

Or you can login here (admin/admin)

http://www.warningtrack.net/cgi-bin/database/players.cgi?db=players



Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Here's what I did.

I went to your site -- just the default user is fine for my purposes.

I did a "List All" and everything worked fine.

Then I changed the URL in the browser to include &PlayerID=2. I got two results -- Bobby Abreu and Sandy Alomar, Jr. Then I changed the URL in the browser again, this time just adding &ww=1. I got just Bobby Abreu. That's what you want, right?

What is the URL from the browser where you got the results you mentioned earlier? And what is the URL from the browser from the page before you got the results?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Here's the URL I had problems with:

http://www.warningtrack.net/cgi-bin/database/players.cgi?db=players&uid=default&view_records=1&PlayerID=*&sb=2&nh=7&mh=1

His playerID is #1 so I guess its posting the stats from the players using 1, 10, 11 and 12...

I guess the problem is that the PlayerID field isn't specified in the URL...this is the way its linked to from the List All page...which part of sub html_record needs to be tweaked? :)



Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Oh, I get it! (I'm a little dense sometimes.)Smile

In your sub html_record_long, before the search is made, add $in{'ww'} = 1;.

So that would be before the line that looks like

my ($status2,@hits2) = &query("view");

(I'm not sure what your line actually looks like, but it should be pretty close to that.)

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
Carol,

Hmmm...still don't quite follow (you think you're dense???? :))

Here's what I have in my sub html_record_long. :) Are you sure the problem is there? The links on sub html_record seem to be the problem? Just what I concluded, I could be wrong! :)

Here's the code

In Reply To:
sub html_record_long {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
$row_color[0] = "FFFFFF";
$row_color[1] = "DEDCDC";

print qq|
|;
my (%rec) = @_; # Load any defaults to put in the VALUE field.
if ($db_total_hits > 1) {

# create links to previous and next records
$next_url = $ENV{'QUERY_STRING'};
$next_url =~ s/\&nh=\d+//;
$next_url =~ s/\&StatSort=\d+//;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;
if ($prev_hit) {
$previous = qq~<a href="$db_script_url?$next_url&nh=$prev_hit"><$font>Previous</font></a>~;
}
else { $previous = " "; }
if ($next_hit <= $db_total_hits) {
$next = qq~<a href="$db_script_url?$next_url&nh=$next_hit"><$font>Next</font></a>~;
}
else { $next = " "; }
# create link back to short display
$list_url = $next_url;
$list_url =~ s/\&mh=\d+//;
$mh = $db_max_hits;
$lh = int(($nh-1)/$mh) + 1;
$list = qq~<a href="$db_script_url?$list_url&nh=$lh"><$font>Back to record list</font></a>~;
# print out the links
print qq|
<table>
<tr><td width=50%>$previous</td>
<td width=50% align=right>$next</td></tr>
<tr><td colspan=2 align=center>$list</td></tr>
<tr><td colspan=2 align=center><$font>Record $nh of $db_total_hits</font></table>
|;

}
($db_auto_generate and print &build_html_record(%rec) and return);
my $font_color = 'Font face="Times New Roman, Arial, Helvetica" Size=2 Color=#800000';
my $font = 'Font face="Times New Roman, Arial, Helvetica" Size=2';

print qq|
<table border="0" cellspacing="0" width="275">
<tr>
<td bgcolor="#800000" width="226"><font color="#FFFFFF"><b>$rec{'First'} $rec{'Last'}</b></font></td>
<td bgcolor="#800000" width="122" align="right"><font color="#FFFFFF"><b>$rec{'Position'}</b></font></td>
<td bgcolor="#800000" width="3" align="right"> </td>
</tr>
<tr>
<td bgcolor="#000000" width="226"><font color="#FFFFFF"><b><a href="http://www.warningtrack.net/teams/indians" style="color: #FFFFFF">$rec{'Team'}</a></b></font></td>
<td bgcolor="#000000" width="122" align="right"><font color="#FFFFFF"><b>#$rec{'Jersey'}</b></font></td>
<td bgcolor="#000000" width="3" align="right"> </td>
</tr>
</table> <p>
|;
&switch_to_hitting;
$StatSort = $in{'StatSort'};
$sort_link = $ENV{'QUERY_STRING'};
$sort_link =~ s/\&StatSort=\d+//;
undef %in;
$rec{'PlayerID'} =~ s/<?.B>//g;
$in{'PlayerID'} = $rec{'PlayerID'};
if ($StatSort) { $in{'sb'} = $StatSort;}else { $in{'sb'} = 2;}
$in{'mh'} = 100;
my ($status2,@hits2) = &query("view");
if ($status2 eq "ok") {
my ($numhits2) = ($#hits2+1) / ($#db_cols+1);
print "<table cellspacing=0 width=420><tr>";
for ($k=2;$k<=$#db_cols;++$k) { print qq|<td bgcolor=#800000 align=center> <font color=#FFFFFF size=2><b> <a href="$db_script_url?$sort_link&StatSort=$k" style="color: #FFFFFF">$db_cols[$k]</a></b></font></td>|; }
print "</tr>";
for (0 .. $numhits2 - 1) {
%rec2 = &array_to_hash($_, @hits2);

print qq|<tr bgcolor="$row_color[$color]">\n|;
$color= !$color; for ($k=2;$k<=$#db_cols;++$k) {
print "<td align=center><font size=2>$rec2{$db_cols[$k]}</font></td>";
}
}
print "</table>";
}
&switch_to_pitching;
if ($StatSort) { $in{'sb'} = $StatSort;}else { $in{'sb'} = 2;}
my ($status3,@hits3) = &query("view");
if ($status3 eq "ok") {
my ($numhits3) = ($#hits3+1) / ($#db_cols+1);
print "<table cellspacing=0 width=420><tr>";
for ($k=2;$k<=$#db_cols;++$k) {
print qq|<td align=center bgcolor=#800000 width=52><font size=2 color=#FFFFFF><b><a href="$db_script_url?$sort_link&StatSort=$k" style="color: #FFFFFF">$db_cols[$k]</a></b></font></td>|;
}
print "</tr>";
for (0 .. $numhits3 - 1) {
%rec3 = &array_to_hash($_, @hits3);
unless ($j) {
print qq|<tr bgcolor="DEDCDC">|;
$j = 1;
}
else {
print qq|<tr bgcolor="FFFFFF">|;
$j = 0;
}
print qq|<tr bgcolor="$row_color[$color]">\n|;
$color= !$color; for ($k=2;$k<=$#db_cols;++$k){
print "<td align=center><font size=2>$rec3{$db_cols[$k]}</font></td>";
}
}
print "</table>";
}
&switch_to_players;

print qq|
<p><TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=0 BGCOLOR="#FFFFFF">
|;
if ($per_admin) {
print qq|
<TR><TD ALIGN="Left" VALIGN="TOP" WIDTH="20%"><$font_color><b>PlayerID:</b></FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'PlayerID'}</font></TD></TR>

<TR><TD ALIGN="Left" VALIGN="TOP" WIDTH="20%"><$font_color><b>RosterID:</b></FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'RosterID'}</font></TD></TR>
|;
}
print qq|
<TR><TD ALIGN="Left" VALIGN="TOP" WIDTH="20%"><font size=2 color=000080><b>Height:</b></FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Height'}</font></TD></TR>
<TR><TD ALIGN="Left" VALIGN="TOP" WIDTH="20%"><font size=2 color=000080><b>Weight:</b></FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Weight'} lbs.</fFont></TD></TR>
<TR><TD ALIGN="Left" VALIGN="TOP" WIDTH="20%"><font size=2 color=000080><b>Batting:</b></FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Batting'}</font></TD></TR>
<TR><TD ALIGN="Left" VALIGN="TOP" WIDTH="20%"><font size=2 color=000080><b>Throwing:</b></FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Throwing'}</font></TD></TR>
<TR><TD ALIGN="Left" VALIGN="TOP" WIDTH="20%"><font size=2 color=000080><b>Birthdate:</b></FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Birthdate'}</font></TD></TR>
</TABLE>|;

if ($per_add) {
if ($rec{'Position'} eq 'Pitcher') {
print qq|<p><b><font size=3><a href="$db_script_url?db=pitching&uid=$db_uid&PlayerID=$rec{'PlayerID'}&add_form=1">Add Pitching Stats for $rec{'First'} $rec{'Last'}</a></font></b><p>
|;
}
else {
print qq|<p><b><font size=3><a href="$db_script_url?db=hitting&uid=$db_uid&PlayerID=$rec{'PlayerID'}&add_form=1">Add Hitting Stats for $rec{'First'} $rec{'Last'}</a></font></b><p> |;
}
}
print qq|
|;
}
:) I must say, this is an amazing use of DBMan...are there any others this complex? This one boggles the mind...that StatSort thing of yours is awesome...you'll definetly be credited in our "About" section as a MAJOR help in building our site as a whole! :)




Quote Reply
Re: Some Odd Questions :) Part 4! In reply to
I'm 99% certain this is where the problem is. Add the code in red below:

Code:

$StatSort = $in{'StatSort'};
$sort_link = $ENV{'QUERY_STRING'};
$sort_link =~ s/\&StatSort=\d+//;
undef %in;
$rec{'PlayerID'} =~ s/<?.B>//g;
$in{'PlayerID'} = $rec{'PlayerID'};
if ($StatSort) { $in{'sb'} = $StatSort;}else { $in{'sb'} = 2;}
$in{'mh'} = 100;
$in{'ww'} = 1;
my ($status2,@hits2) = &query("view");
If the problem was within the link, you wouldn't be getting just one player on the page. The search for the statistics is not based on anything within the URL, but is taken from the record. (I don't know if this explains the problem or not, but I'm pretty sure that adding that line will do the trick.)


JPD
http://www.jpdeni.com/dbman/
> >