Creating a database for screened movie club films

Hi

I am the web guy at http://www.spirituellfilm.no/ a Norwegian spiritual film club. We hold screenings once a month, and I have created a web page called film archive: http://www.spirituellfilm.no/meny/osf_FilmArkiv.html which contains probably around 40-50 movies. It is growing from month to month.

I am trying to figure out a better way to create my movie of the month html pages.

I am thinking about using the CMS Modx Revolution for the site.

  • What is a good way of dealing with data that is similar from month to month? I am basically filling out a header field, a left column area, a right column area and a footer.

  • Can I create a database or something like that in which I fill in the new info and it will be called into a movie template? Etc…

  • A better way?

I just need some help putting my head on the right path as to figuring out a good way of handling similar data. And asking the correct questions.

Thank you…:slight_smile:

As it stands each month contains only one film. The film has a title and some kind of release date eg /100327-orbs.htm shown in the url.

You could keep the film detail in a database.

Films_table

slug
release_date
title
feature
cover_image
article_text

Sample row

100327-orbs
2010-03-27
Orbs
1
orbs_image.jpg
“all about the film called Orb …”

Then to collect up all films for 2010 you would have a select which does the equivalent of:


SELECT
 slug
, title
, cover_image 
FROM Films_table
WHERE 
YEAR(release_date) = '2010'

Untested

Then have one PHP file, index.php which takes an argument which is the slug:

index.php?film=100327-orb

index.php


<?php
include 'header.php' ;

// check the slug is valid
// else send the user to the start of your site
// try and find it in the database
// display the details
// else say you cannot find it

include 'footer.php' ;
?>

Then when that is set up, create a mod_rewrite rule in a .htaccess file which spots a request like

/films/100327-orb.html

and then translates that to get the data from

index.php?film=100327-orb

Maybe I have explained it the wrong way round, but that is how you could approach creating a dynamic page of years of films, and how you would keep your seo friendly urls and yet maintain only one page (index.php) which would in effect serve up all links to your films.

Is it complex? first time you do it, yes.

Is this a trick worth learning? It depends, but generally, yes.

Can we help you do it? yes.

Is this what you are looking for?

Hey Cups

---- Is this what you are looking for?

It sure seems like it!
I would like to learn how to do this and add this to the site I plan to create through the CMS Modx Revolution.

How do we proceed from here?

Thank you very much for your reply Cups!

I am not familiar with ModX.

I am explaining how you would traditionally approach this task using a combination of PHP/Mysql - so I am happy to go along until you hit ModX specific problems, then I will be unable to answer them.

A question though, you explain featured film of the month, are there other films which are not featured film of the month?

Why don’t you start off by creating a first iteration of your films table?

Then paste here the output from the following sql statement


DESCRIBE <put-your-table-name-here>

If you do not know how to approach this task do a bit of searching first, then ask again here.

PS I am not on this forum all day long, so it is completely normal that anyone else can just dive in and help you along with this.

Thank you very much for your reply Cups!

You are OK, its my last day as member of the month, so I am making an effort, see?

– Warning long post – But I need help with this –

I have figured out some and need more help. I am including a link to an image to visually show everyone here the variables that I need to figure out how to create. I also created a database and a table.

We have no other movies on the site then the film of the month.

I started up Xamp and went to http://localhost/phpmyadmin/
Created a new database which I called moviedatabase.
Created a table called month.
Filled in variables:

Header_Norgespremiere (premiere in Norway) - TEXT (50)
Header_Movietitle - TEXT (50)
Header_Date - DATE (40)

Left_topimage - BINARY (1)
Left_undertext - TEXT (40)
Left_image2 - BINARY (1)
Left_undertext2 - TEXT (40)
Left_image3 - BINARY (1)

Footer_embedtitle - TEXT(50)
Footer_embedmovie - BINARY (1)
Footer_movieinfo - TEXT(250)

Saved table.
Table ‘moviedatabase’, ‘month’ has been created.

CREATE TABLE moviedatabase.month (
Header_Norgespremiere TEXT NOT NULL ,
Header_Movietitle TEXT NOT NULL ,
Header_Date DATE NOT NULL ,
Left_topimage BINARY( 1 ) NOT NULL ,
Left_undertext TEXT NOT NULL ,
Left_image2 BINARY( 1 ) NOT NULL ,
Left_undertext2 TEXT NOT NULL ,
Left_image3 BINARY( 1 ) NOT NULL ,
Right_movietext TEXT NOT NULL ,
Footer_embedtitle TEXT NOT NULL ,
Footer_embedmovie BINARY( 1 ) NOT NULL ,
Footer_movieinfo TEXT NOT NULL
) ENGINE = MYISAM ;

– I barely know a little bit if MySQL and do not know if the above is correct. I do not know how or where to proceed from here.

Ok.

I have a clearer picture now of where you are at the moment and where you want to go.

I am going to say a couple of things in order to keep you on the normal path most of us probably follow when starting out - you can deviate from all of these guides if you want, but be prepared to explain why you want to break them for the time being.

1 Don’t keep the binary data in your database, just store the file name for now.

When you can successfully argue with yourself and others why you should keep it in your database then you will have fully understood the benefits - and then you can do it, but most people just store the file name.

large_image varchar(100) example “orbs-the-veil-is-lifting-large.jpg”

2 Try to re-use the title of the film as the name of the image, that way you can find it on your own file system and you have a naming convention you can follow.

3 Don’t try and do everything at once.

Make a really simple sample system on which you learn, and then add fields once you have grasped the main concepts and got a simple skeleton sample working to your satisfaction.

4 Don’t try and store display information in your database row definitions. eg

Footer_movieinfo TEXT NOT NULL

That is bad practice, just call it something which drops the display information “Footer_” etc

What happens if you move that info into a left hand channel on your website? - you will have to change your database otherwise that info is misleading.

So, make a simpler skeleton system for now, something which contains fewer fields, but should give you enough to get your teeth into.



test_films <- table name
=======
id INT AUTO-INCREMENT
film title VARCHAR 100
release_date date
large_image VARCHAR 120
summary VARCHAR 255
description TEXT

Go ahead and Populate that with say, 3 films’ data - make the dates 3 months, Dec 2009, Jan 2010 and Feb 2010.

This becomes your playground upon which you can then build the supporting PHP pages.

I have suggested you have a unique ID field in your table which auto-increments so that each time you add a new film this will assign the next number up.

http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

Ok, then create a folder on your localhost server and put a file in it which retrieves just the id and title of each of your 3 test films.

Loop through that list and echo them onto the page in a UL

This will make a menu of available films.

Make each of those links in the fashion:


<li><a href="index.php?id=1">Orbs the veil is lifting</a></li>

To achieve the above you will have to connect to your database, loop through an array of results and use PHP to output HTML.

Don’t worry about creating correctly formed HTML at this stage.

Now, put in some conditional code which detects that $_GET[‘id’] has been set and echo a different message onto the page, which contains say, the title, summary and image of the film.

Come back if you get stuck, or search around on this forum for answers.

I have created these values:
MySQL:
id - autoincrement - (which was kinda hidden at first but found the auto after some searching.)
film_title varchar(100)
screening_date date
large_image varchar(120)
summary varchar(255)
description text

I populated these with three films

In PHP:
<?php

$db = mysql_connect(“localhost”, “root”, “”);
$db_select = mysql_select_db(“moviedatabase”, $db);

$result = mysql_query(“SELECT * FROM test_films”, $db);

while ($row = mysql_fetch_array($result)) {

echo “<ul>”;
echo “<li>$row[id]</li>”;
echo “<li>$row[film_title]</li>”;
echo “<li>$row[screening_date]</li>”;
echo “<li>$row[large_image]</li>”;
echo “<li>$row[summary]</li>”;
echo “</ul>”;

echo "&lt;br/&gt;";
echo "&lt;br/&gt;";

}
?>

Print out on the screen became:
* 1
* Buddhas Lost Children
* 2009-12-12
*
* FILMTEKNISK INFORMASJON Originaltittel: Buddha’s Lost Children Filmslipp: 2006 Regissør: Mark Verkerk Produksjonsselskap: EMS Films Produsent: Ton Okkerse, Pim van Co Produksjonsland: Nederland Foto: Rene Heynen Musikk: Bernard Joosten, S. P. Somtow Språ

* 2
* "The Shadow Effect"
* 2010-01-30
*
* FILMTEKNISK INFORMASJON Originaltittel: The Shadow Effect Filmslipp: 2009 Manus: Debbie Ford, Danielle Dorman, Cliff Edwards Regissør: Scott Cervine Produsent: Debbie Ford, Mikki Willis, Julie Stroud Produksjonsselskap: Movies from the Heart Production, 



* 3
* "Something Unknown"
* 2010-02-27
*
* Originaltittel: Something Unknown is doing we don't know what... Filmslipp: 2009 Manus: Telekan, Renée Scheltema Regissør: Telekan, Renée Scheltema Produsent: Paul Verhoeven og The Buddhist Broadcasting Foundation Produksjonsselskap: Telekan Produksjonsla

— Next stage creating links… slowly getting there…:slight_smile:
Thanks Cups! I am posting my progress so others can join in and give tips for better ways of doing this, and others can learn from my progress. I plan to create a tutorial after I have gone through this.

OK, well done.

However adjust the output of your sql query so you just collect up the id and the film title (you are doing "select * "), then create html links out of them, as I described in the last few lines.

Then you are ready to collect and display ALL the detail of just one film.

also the array keys should be quoted:

NOT
echo “<li>$row[id]</li>”;

BUT
echo “<li>$row[‘id’]</li>”;

Which suggests maybe you do not have error reporting turned on, do that now at the top of you php page.


ini_set('show_errors', 1);
error_reporting(E_ALL) ;

See http://www.php.net/manual/en/function.error-reporting.php

That would be display_errors, not show_errors. :wink:

:stuck_out_tongue:

I’m not sure, but I think you’re ‘allowed’ to have unquoted array keys when it’s in a string.

Actually…


&lt;?php
error_reporting(-1);
ini_set('display_errors', true);

$array = array(
  'foo' =&gt; 'bar'
);

echo "I like Mars$array['foo']s.";

/*
  Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in D:\\www\\public\\rig.php on line 9 
*/

?&gt;


&lt;?php
error_reporting(-1);
ini_set('display_errors', true);

$array = array(
  'foo' =&gt; 'bar'
);

echo "I like Mars$array[foo]s.";

/*
  I like Marsbars.
*/

?&gt;

… it appears they have to be unquoted.

Hey Folks

I have been searching for good tutorials to show one record for each page, but am having a difficult time finding tutorials that I need.

Clicking a link in the film archive page which says id = 1 and a link that says id =2 etc. http://localhost/database/film.php?id=1

But I am having a difficult time figuring it out. If someone could share the simple approach that would be good.

Calling in the info related to the id tag. Adding it to the new page. Which means as I see it one only needs two pages. The film archive page containing thumb nails with the titles of the movies. By clicking the thumb nails or title it changes to the page containing the specific movie.

Help please…:slight_smile: