Help - Search - Members - Calendar
Full Version: From blog to dvd collection
Codegrrl.com Forums > Script Help > Tutorial Help
virgo_sexy
Hi there,
since I can't find any DVD collection script that suits my wishes, I thougt it might be possible to create my own, using the BAB as a basic. But I'm already stuck at creating the database, as my MySQL knowledge isn't that much. I've added columns that I want in the table but I'm not sure how to format them in order to create them right. I hope there's someone willing to help me out here.

This is the coding I have until now. Where it says "..??" it means I have no clue on how to add it, of all the other things I'm also not quite sure:

CODE
<?php

mysql_connect ('localhost', 'db_username', 'db_password');
mysql_select_db ('db_name');

$sql = "CREATE TABLE php_dvdcol (
  id int(20) NOT NULL auto_increment,
  title varchar(255) NOT NULL,
  subtitle varchar(255) NOT NULL,
  image ..??
  ean varchar(20) NOT NULL,
  year int(4) NOT NULL,
  release int (10) NOT NULL,
  kijkwijzer ..??
  languages varchar(255) NOT NULL,
  subtitles varchar(255) NOT NULL,
  ratio ..??
  audio ..??
  genre ..??
  region ..??
  color ..??
  length ..??
  director varchar(255) NOT NULL,
  writer varchar(255) NOT NULL,
  producer varchar(255) NOT NULL,
  music varchar(255) NOT NULL,
  studio varchar(255) NOT NULL,
  cast varchar(255) NOT NULL,
  plotline longtext NOT NULL,
  added int(20) NOT NULL,
  PRIMARY KEY  (id),
  UNIQUE KEY id (id)
)";

$result = mysql_query($sql) or print ("Can't create the table 'php_blog' in the database.<br />" . $sql . "<br />" . mysql_error());

mysql_close();
?>



I want it to look like this in the end: http://dvd.in-perfect-harmony.net/8_Mile.pdf

For the image part I want to be able to upload a file, just like uploading joined buttons in Enth. For the 'kijkwijzer' part I have some small images that I would love to be able to select or anything to display them.

Well, anyone who wants to help me out?

If this is way over my head (as building scripts is not what I normally do) please tell me, so I can let go of my little dream having my own dvd collection displayed the way I want it.

Thanks so much in advance!
Amelie
What those fields should be formatted as depends on what you want to store in them and how long that data is going to be.

I would suggest the following structure:

SQL
CREATE TABLE php_dvdcol (
id int(20) NOT NULL auto_increment,
title varchar(255) NOT NULL,
subtitle varchar(255) NOT NULL,
image varchar(255) NOT NULL,
ean varchar(20) NOT NULL,
year int(4) NOT NULL,
release int(10) NOT NULL,
kijkwijzer enum('pic1.gif','pic2.gif','pic3.gif') NOT NULL DEFAULT 'pic1.gif',
languages varchar(255) NOT NULL,
subtitles varchar(255) NOT NULL,
ratio varchar(255) NOT NULL,
audio varchar(255) NOT NULL,
genre varchar(255) NOT NULL,
region varchar(255) NOT NULL,
color varchar(255) NOT NULL,
length varchar(10) NOT NULL,
director varchar(255) NOT NULL,
writer varchar(255) NOT NULL,
producer varchar(255) NOT NULL,
music varchar(255) NOT NULL,
studio varchar(255) NOT NULL,
cast varchar(255) NOT NULL,
plotline longtext NOT NULL,
added int(20) NOT NULL,
PRIMARY KEY (id)
)


For the image field, I have done it as enum() - that means you can only select from those values. I would advise against storing images in MySQL (I'm not even sure how to do it, but I've heard a lot of problems from people who have done it), so what you could have code like this:

CODE
<img src="<?php echo $image; ?>" alt="Image" />


Where $image is the value from the database, in my example pic1.gif, pic2.gif or pic3.gif. Of course, you can just make that a varchar field and type the URL to the image yourself, if you don't want to be able to choose from predefined ones (because once the table has been created, you won't be able to easily add any more images or anything).

If you want to know more about the different MySQL data types, have a look at the documentation. smile.gif
virgo_sexy
Thank you so much biggrin.gif wub.gif

I'll definately look in to the documentation! I feel this is going to take a whole lot of time, but I keep hoping that I'll make it and get my very own dvd collection smile.gif
loadx
heheh, you should also pool the data from imdb using Imdb Class
http://sourceforge.net/project/showfiles.php?group_id=83532

Usage: whatever.php?movie=grave of the fireflies
using the first result as the movie imdb grabs..no error checking so dont post this somewhere people can get to.

CODE

set_time_limit(120);

include_once ("imdb.class.php");

$search = new imdbsearch ();
$search->setsearchname (urlencode($_GET['movie']));
$results = $search->results();

$movie = new imdb ($results[1]->imdbID);
$movie->setid ($results[1]->imdbID);
    
#sample methods to find out more var_export($movie);
//title: $movie->title();
//year: $movie->year();
//Genre: ".$movie->genre();
//Plot: $movie->plotoutline();
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.