|
Posted by ME on 03/20/06 23:09
Yes it is for a round knockout tournament, it uses a ini file for data. I
want to convert the script to be used in a database for a site. Here is the
rest of the code. I found it on the internet, the guys was giving the code
for people to download for free. The top part ot the code above the php code
is actually the ini file that was name .txt that i switch to .php thinking i
could use it for variable and getting info from the db, which i have found I
can't, and need to recode everything but the math.
[code]
________________________________________________________________________________________________________________
[bracket]
columns = 5;
column_width = 120;
title = "Your Title Here";
[column7]
1 = ""
2 = ""
3 = ""
4 = ""
5 = ""
6 = ""
7 = ""
8 = ""
9 = ""
10 = ""
11 = ""
12 = ""
13 = ""
14 = ""
15 = ""
16 = ""
17 = ""
18 = ""
19 = ""
20 = ""
21 = ""
22 = ""
23 = ""
24 = ""
25 = ""
26 = ""
27 = ""
28 = ""
29 = ""
30 = ""
31 = ""
32 = ""
33 = ""
34 = ""
35 = ""
36 = ""
37 = ""
38 = ""
39 = ""
40 = ""
41 = ""
42 = ""
43 = ""
44 = ""
45 = ""
46 = ""
47 = ""
48 = ""
49 = ""
50 = ""
51 = ""
52 = ""
53 = ""
54 = ""
55 = ""
56 = ""
57 = ""
58 = ""
59 = ""
60 = ""
61 = ""
62 = ""
63 = ""
64 = ""
[column6]
1 = ""
2 = ""
3 = ""
4 = ""
5 = ""
6 = ""
7 = ""
8 = ""
9 = ""
10 = ""
11 = ""
12 = ""
13 = ""
14 = ""
15 = ""
16 = ""
17 = ""
18 = ""
19 = ""
20 = ""
21 = ""
22 = ""
23 = ""
24 = ""
25 = ""
26 = ""
27 = ""
28 = ""
29 = ""
30 = ""
31 = ""
32 = ""
[column5]
1 = "team name between quotes"
2 = ""
3 = ""
4 = ""
5 = ""
6 = ""
7 = ""
8 = ""
9 = ""
10 = ""
11 = ""
12 = ""
13 = ""
14 = ""
15 = ""
16 = ""
[column4]
1 = ""
2 = ""
3 = ""
4 = ""
5 = ""
6 = ""
7 = ""
8 = ""
[column3]
1 = ""
2 = ""
3 = ""
4 = ""
[column2]
1 = ""
2 = ""
[column1]
1 = "<i>Champion</i>"
________________________________________________________________________________________________________________
<?php
//----------------------------------------------------------------------
$DATA = parse_ini_file("data_sheet.php", true);
$COLUMNS = $DATA["bracket"]["columns"];
$COLUMN_WIDTH = $DATA["bracket"]["column_width"];
$TABLE_WIDTH = $COLUMN_WIDTH * $COLUMNS;
//----------------------------------------------------------------------
?>
<html>
<head>
<title><?= htmlspecialchars($DATA["bracket"]["title"]); ?></title>
<style type="text/css">
P {
font-family : Arial, Helvetica, sans-serif;
font-size : 11px;
font-weight : normal;
color : Black;
}
EM {
font-family : Arial, Helvetica, sans-serif;
font-size : 11px;
font-weight : normal;
color : #CC0000;
}
A {
font-family : Arial, Helvetica, sans-serif;
font-size : 11px;
font-weight : normal;
color : Blue;
}
.line {
font-family : Arial, Helvetica, sans-serif;
font-size : 11px;
font-weight : normal;
padding : 1px 3px 1px 3px;
}
.line-right {
font-family : Arial, Helvetica, sans-serif;
font-size : 11px;
font-weight : normal;
padding : 1px 3px 1px 3px;
border-right : 1px solid Red;
}
.line-under {
font-family : Arial, Helvetica, sans-serif;
font-size : 11px;
font-weight : normal;
padding : 1px 3px 1px 3px;
border-bottom : 1px solid Green;
}
.line-under-right {
font-family : Arial, Helvetica, sans-serif;
font-size : 11px;
font-weight : normal;
padding : 1px 3px 1px 3px;
border-bottom : 1px solid Blue;
border-right : 1px solid Grey;
}
.right {
font-family : Arial, Helvetica, sans-serif;
font-size : 11px;
font-weight : bold;
color : Green;
}
.wrong {
font-family : Arial, Helvetica, sans-serif;
font-size : 11px;
font-weight : bold;
color : Red;
}
</style>
</head>
<body bgcolor="blue" leftmargin="20" topmargin="20" rightmargin="20"
bottommargin="20" marginwidth="20">
<div align="center">
<table width="700" border="0" cellspacing="0" cellpadding="20"
bgcolor="gray">
<tr>
<td align="center" valign="top">
<p>
<h1 style="font-family: Arial, Helvetica, sans-serif;">
<?= htmlspecialchars($DATA["bracket"]["title"]); ?>
</h1>
<table width="<?= $TABLE_WIDTH ?>" border="0" cellspacing="0"
cellpadding="0">
<?php
for ($x=1; $x<=pow(2, $COLUMNS); $x++) {
// open the row
printf('<tr>');
// draw each of the columns in this row...
for ($y=1; $y<=$COLUMNS; $y++) {
// begin with a default style
$style = "line";
$value = "";
// Determine the content for the data cells (if there is any) and
// add the underline style always
if (($x % pow(2, $y)) == pow(2, $y-1)) {
$round = "column" . ($COLUMNS - $y +1);
$posit = ceil($x/pow(2, $y));
$data = (isset($DATA[$round][$posit])) ?
trim($DATA[$round][$posit]) : '';
$parts = split("\|", $data);
$value = array_shift($parts);
$value = sprintf($value);
$style .= "-under";
}
// Add the right bar line for cells that need it...
if ($y != $COLUMNS) {
if ((($x + pow(2, $y-1) - 1) % pow(2, $y+1)) >= pow(2, $y)) {
$style .= "-right";
}
}
// make sure we don't print empty content
if (empty($value)) {
$value = " ";
}
// draw this cell
printf('<td width="%d" class="%s">%s</td>',
$COLUMN_WIDTH, $style, $value);
print("\n");
}
// close the row
printf("</tr>\n");
}
?>
</table>
</p>
<p align="left">
****NOTE****<br>
</p>
</td>
</tr>
</table>
</div>
</body>
</html>
[/code]
Any help with converting code to be used with a db would be greatly
appreciated.
[Back to original message]
|