Forum Moderators: open
I would like it to show something like so
QBs (15)
RBs (22)
WRs (9)
TEs (18)
and so on. Thanks to anyone with help.
Using the SSI option, put the following in your .shtml page. It's called an SSI directive and basically means include the output from this file or program in this page at this location:
<!--#include virtual="path_to/summary_script.cgi" -->
Where "summary_script.cgi" is a server-side program that gets the totals and outputs a formated block to be included in the page. It can be in any server side language you're familiar with.
The following is for logic only, roughly what summary_script.cgi would do. I'd do something like this:
$output_div = '<div id="summary"><ul>';
for each $table ('QB','RB','WR','TE') {
$select = "select count(*) from $table";
$cnt = mysql_query_output($select);
$output_div .= "<li>$table ($cnt)</li>\n";
}
$output_div .= '</ul></div>';
print "content-type: text/html\n\n";
print "$output_div";
It will vary based on the programming language you use, but the logic is the same. The SSI (include) calls this program to be included in the page. The program runs, starts a div for your stats, then as you read through the database, add to that div with the results. It finishes by printing out the div, which appears in the space where the SSI directive is. You can remove the bullets on the <li> and style the rest of the block with CSS.
If you do it with PHP, the concept is all still the same, you'd just read in the database at the point in the page where you need it.
How do I point the code to the right database since I have so many?
Database, or table? The "code" I posted is not valid code for PHP. it is for example only, My PHP is a bit rusty. :-) It's to show the logic of how you'd loop through your tables. When you loop through the list, "$table" becomes the value for each item in the list.
for each $table ('QB','RB','WR','TE') { ....
So what it should do, if you add echo
for each $table ('QB','RB','WR','TE') {
$select = "select count(*) from $table";
echo "$select <br>\n";
is this:
$select = "select count(*) from QB";
$select = "select count(*) from RB";
$select = "select count(*) from WR";
$select = "select count(*) from TE";
Review loops in PHP for the proper language syntax.