Posted: 2007-08-05 01:40:27
Sorry been busy lately. I haven't had time to neatly incorporate this script with PK's functions.
1. First you need to create a column in your movies table called PERIOD. I haven't had time to add this into the PHP code below. I created the column using the GUI editor which comes with MySQL administrator.
2. Here is the code for the PHP page which will go through all the movies and categorise them by period. Save the file in the same folder as your index.php and call it processPeriodForMovies.php
In the PHP code below you need to initialise the details of the database access, these are the ones at the top of the mdb_config.inc file. When you open the page in your browser it should run.
As you can see I am using the "." after some of the years because without it is not sorting properly.
3. Then edit the the mdb_config.inc file and
these lines at the bottom
4. Edit the language file in
languages\english.inc (which ever language you are using)
add this line above the # PLURALS LINE
I have a bad memory so I might have missed a step, so if you have any problems post here. Hopefully when I find time I can incorporate this script better with PKs code.
I am using 3.03 version.
1. First you need to create a column in your movies table called PERIOD. I haven't had time to add this into the PHP code below. I created the column using the GUI editor which comes with MySQL administrator.
2. Here is the code for the PHP page which will go through all the movies and categorise them by period. Save the file in the same folder as your index.php and call it processPeriodForMovies.php
In the PHP code below you need to initialise the details of the database access, these are the ones at the top of the mdb_config.inc file. When you open the page in your browser it should run.
Code: Select all
<html>
<head> <title>Process Period For Movies</title>
</head>
<body>
<?php processPeriodForMovies(); ?>
</body>
</html>
<?php
function processPeriodForMovies()
{
/* initialise the database details */
$user = "yourusername";
$pass = "youruserpassword";
$db = "dbname";
$tablename = "tablename";
$link = mysql_pconnect( "localhost", $user, $pass );
if ( ! $link )
die( "Couldn't connect to MySQL" );
mysql_select_db( $db, $link )
or die ( "Couldn't open $db: ".mysql_error() );
//SELECT * FROM movies LIMIT 0, 200"
$result = mysql_query( "SELECT * FROM $tablename " ) or die(mysql_error());
while ( $a_row = mysql_fetch_array( $result ) )
{
$period='';
$y = $a_row[YEAR];
if ($y == 2007) {
$period="2007.";
}
elseif ($y == 2006) {
$period="2006.";
}
elseif ($y == 2005) {
$period="2005.";
}
elseif ( $y >= 2000 ) {
$period="2000-04";
}
elseif ( $y >= 1990 ) {
$period="1990s";
}
elseif ( $y >= 1990 ) {
$period="1990s";
}
elseif ( $y >= 1980 ) {
$period="1980s";
}
elseif ( $y >= 1970 ) {
$period="1970s";
}
elseif ( $y >= 1960 ) {
$period="1960s";
}
elseif ( $y >= 1950 ) {
$period="1950s";
}
elseif ( $y >= 1940 ) {
$period="1940s";
}
elseif ( $y >= 1930 ) {
$period="1930s";
}
elseif ( $y >= 1920 ) {
$period="1920s";
}
elseif ( $y >= 1910 ) {
$period="1910s";
}
else{
$period="unknown";
}
$lsSQL = "UPDATE $tablename SET Period='$period' WHERE NUM=$a_row[NUM]";
print "$a_row[ORIGINALTITLE] - $y - $period <br/>\n $lsSQL <br>";
$updateresult = mysql_query($lsSQL);
print $updateresult."<br>";
}
}
?>
3. Then edit the the mdb_config.inc file and
these lines at the bottom
Code: Select all
//----
$this->config['panels'][9]['dbfield'] = "PERIOD";
$this->config['panels'][9]['display'] = TRUE;
$this->config['panels'][9]['minimum'] = 4;
4. Edit the language file in
languages\english.inc (which ever language you are using)
add this line above the # PLURALS LINE
Code: Select all
$this->lang['PERIOD'] = "Period";
I am using 3.03 version.