Hi,
Here it is:
Code: Select all
<?php
if (isset($_GET['id'])) {
$select = "SELECT genretypes.*, genres.*, movies.* FROM movies INNER JOIN genres ON genres.MovieID = movies.MovieID INNER JOIN genretypes ON genres.GenreTypeID = genretypes.GenreTypeID WHERE movies.MovieID = '" . $_GET['id'] . "' ORDER BY movies.MovieID";
$result = mysql_query($select);
if (mysql_num_rows($result) > 0) {
while ($movies = mysql_fetch_array($result)) {
echo "<div style=\"overflow: auto;\">";
echo "<center><h3>" . stripslashes($movies['Title']) . "</h3></center>";
echo "<br><br>";
echo "<div style=\"float: right; padding-right: 150px; height: 400px; \">";
if (strlen($movies['Filename']) > 0) {
echo '<img src="Images/Movies/' . $movies['Filename'] . '" width="246" height="365" />';
}
echo "</div>";
echo "<div style=\"float: left; padding-left: 150px; padding-top: 50px; \">";
?>
<table>
<tr height="40">
<td align="right">
<strong>Director/s: </strong>
</td>
<td>
<?php echo $movies['Director1']; ?>
</td>
<td>
<?php echo $movies['Director2']; ?>
</td>
</tr>
<tr height="40">
<td align="right">
<strong>Genre: </strong>
</td>
<td>
<?php echo $movies['Genre']; ?>
</td>
</tr>
<tr height="40">
<td align="right">
<strong>Rating: </strong>
</td>
<td>
<?php
if ($movies['Rating'] == 0)
echo "N/A";
else
echo $movies['Rating'];
?>/10
</td>
</tr>
<tr height="40">
<td align="right">
<strong>Movie Release Date: </strong>
</td>
<td>
<?php
if (date("d/m/Y", strtotime($movies['MovieReleaseDate'])) == "01/01/1970")
echo "N/A";
else
echo date("d/m/Y", strtotime($movies['MovieReleaseDate']));
?>
</td>
</tr>
<tr height="40">
<td align="right">
<strong>DVD Release Date: </strong>
</td>
<td>
<?php
if (date("d/m/Y", strtotime($movies['DVDReleaseDate'])) == "01/01/1970")
echo "N/A";
else
echo date("d/m/Y", strtotime($movies['DVDReleaseDate']));
?>
</td>
</tr>
<?php
if (isset($_SESSION['user']) && $_SESSION['user'] == true) {
?>
<tr height="40">
<?php
$select = "SELECT * FROM favorites WHERE UserID = " . $_SESSION['userinfo']['id'] . " AND MovieID = " . $_GET['id'];
$isfavorite = mysql_query($select);
if (mysql_num_rows($isfavorite) == 0) {
?>
<td colspan="2" align='center'><a href="addtofavs.php?id=<?php echo $movies['MovieID'] ?>">Add this Movie to my Favorite Movies</a></td>
<?php
} else {
?>
<td colspan="2" align='center'><a href="removefromfavs.php?id=<?php echo $movies['MovieID'] ?>">Remove this Movie from my Favorites Movies</a></td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
--
-- Table structure for table `genres`
--
CREATE TABLE IF NOT EXISTS `genres` (
`GenreID` int(8) NOT NULL AUTO_INCREMENT,
`MovieID` int(8) NOT NULL,
`GenreTypeID` int(8) NOT NULL,
PRIMARY KEY (`GenreID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `genres`
--
INSERT INTO `genres` (`GenreID`, `MovieID`, `GenreTypeID`) VALUES
(1, 3, 1),
(2, 3, 2),
(3, 7, 2),
(4, 7, 3);
-- --------------------------------------------------------
-- Table structure for table `genretypes`
--
CREATE TABLE IF NOT EXISTS `genretypes` (
`GenreTypeID` int(8) NOT NULL AUTO_INCREMENT,
`Genre` varchar(20) NOT NULL,
PRIMARY KEY (`GenreTypeID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
--
-- Dumping data for table `genretypes`
--
INSERT INTO `genretypes` (`GenreTypeID`, `Genre`) VALUES
(1, 'Action'),
(2, 'Comedy'),
(3, 'Family'),
(4, 'History'),
(5, 'War'),
(6, 'Crime'),
(7, 'Adventure'),
(8, 'Thriller'),
(9, 'Romance'),
(10, 'Drama'),
(11, 'Fantasy');
-- --------------------------------------------------------
-- Table structure for table `movies`
--
CREATE TABLE IF NOT EXISTS `movies` (
`MovieID` int(8) NOT NULL AUTO_INCREMENT,
`Title` varchar(100) NOT NULL,
`Review` text NOT NULL,
`Rating` int(2) NOT NULL,
`Director1` varchar(30) NOT NULL,
`Director2` varchar(30) NOT NULL,
`DVDReleaseDate` date DEFAULT NULL,
`MovieReleaseDate` date DEFAULT NULL,
`Filename` varchar(100) NOT NULL,
PRIMARY KEY (`MovieID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
-- Dumping data for table `movies`
--
INSERT INTO `movies` (`MovieID`, `Title`, `Review`, `Rating`, `Director1`, `Director2`, `DVDReleaseDate`, `MovieReleaseDate`, `Filename`) VALUES
(3, 'Avatar', 'In the epic action adventure Avatar, James Cameron, the director of Titanic, takes us to a spectacular new world beyond imagination. On the distant moon Pandora, a reluctant hero embarks on a journey of redemption and discovery as he leads a heroic battle to save a civilization.\r\n\r\nThe film was first conceived by Cameron 14 years ago, when the means to realize his vision did not yet exist. Now, after four years of actual production work, Avatar delivers a fully immersible cinematic experience of a new kind, where the revolutionary technology invented to make the film, disappears into the emotion of the characters and the sweep of the story.', 8, 'James Cameron', '', '2010-04-22', '2009-12-18', 'Avatar.jpg'),
(7, 'Old Dogs', 'Two best friends - one unlucky-in-love divorcee and the other a fun-loving bachelor - have their lives turned upside down when they''re unexpectedly charged with the care of 7-year-old twins while on the verge of the biggest business deal of their lives. The not-so-kid-savvy bachelors stumble in their efforts to take care of the twins, leading to one debacle after another, and perhaps to a new-found understanding of what''s really important in life. ', 5, 'Walt Becker', '', '2010-03-09', '2009-11-25', 'Old Dogs.jpg'),