Monday, September 22, 2008

List of piano chords written in PHP

So I've been teaching myself the programming language PHP -- the result of which is a new website http://www.list-of-chords.com/. This is very exciting since I was able to take the logic in my flash chord finders and expand it to the site.

For those of you who know PHP, I used PHP's output buffer to create static html files, so that the site is more search engine friendly.


function MakeARowofFour($startNum, $endNum) {
global $Roots;
global $NiceNameArray;
global $ShortNameArray;
global $URLNameArray;
global $default_names;
print "<tr>";
for ($table=$startNum; $table<=$endNum; $table++)
{
print "<td>\n";
print"<h2><b>" . $Roots[$table] . " Chords</h2>\n";

//Produce 12 lines for each table
for($counter=0; $counter<6; $counter++)
{

print "&lt;h3><a href=\"$Roots[$table]-$URLNameArray[$counter].htm\">$Roots[$table] $NiceNameArray[$counter] <b>({$Roots[$table]}$ShortNameArray[$counter])</b></a></h3>\n";


ob_start(); //start the PHP output buffer

//Do some PHP stuff to make a page then
$type_short_name = $ShortNameArray[$counter];
$current_root_name = $Roots[$table];
//
//

$piano_chord_type = $NiceNameArray[$counter];
include 'page_generator.php';

//write buffer to file


$myFile = "$Roots[$table]-$URLNameArray[$counter].htm";
$fh = fopen($myFile, 'w') or die("can't open file");


$data = ob_get_contents(); //puts the content of the output buffer into the $data variable


fwrite($fh, $data);


//$stringData = "Tracy Tanner\n";
//fwrite($fh, $stringData);
fclose($fh);
ob_end_clean();

}

print "</td>";
}
print "</tr>";




}
MakeARowofFour(1, 4);
MakeARowofFour(5, 8);
MakeARowofFour(9, 12);
?>

No comments: