I have created movie database. I have list of Genres,
<ul>
<li><a href="movielist.php?id=<?php echo"$id";?>"><?php echo"$genre";?></a></li>
</ul>
In table movies, movie have multiple geners. How to fetch same movie if multiple geners available
(e.g. The Expendables 2 appear in Action | Adventure | Thriller these three geners). How to display movie in each genere?
Actors, Directors, Writers are stored in separate tables. how to fetch them while displaying movie details? Their id's are stored in movies table.
How to display info stored in movies table ?
actor
CREATE TABLE IF NOT EXISTS actor
(id
bigint(12) NOT NULL AUTO_INCREMENT,name
varchar(500) NOT NULL,surname
varchar(500) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
actor
INSERT INTO actor
(id
, name
, surname
) VALUES
(1, 'Sylvester', 'Stallone'),
(2, 'Jason', 'Statham'),
(3, 'Jean-Claude ', 'Van Damme'),
(4, 'Jet', 'Li'),
(5, 'Dolph', 'Lundgren'),
(6, 'Chuck', 'Norris'),
(7, 'Bruce', 'Willis'),
(8, 'Arnold', 'Schwarzenegger'),
(9, 'Terry', 'Crews'),
(10, 'Nan', 'Yu');
director
CREATE TABLE IF NOT EXISTS director
(id
bigint(12) NOT NULL AUTO_INCREMENT,name
varchar(500) NOT NULL,surname
varchar(500) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
director
INSERT INTO director
(id
, name
, surname
) VALUES
(1, 'Simon', 'West');
genres
CREATE TABLE IF NOT EXISTS genres
(id
bigint(12) NOT NULL AUTO_INCREMENT,genre
varchar(500) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=23 ;
genres
INSERT INTO genres
(id
, genre
) VALUES
(1, 'Action'),
(2, 'Adventure'),
(3, 'Animation'),
(4, 'Biography'),
(5, 'Comedy'),
(6, 'Crime'),
(7, 'Documentary'),
(8, 'Drama'),
(9, 'Family'),
(10, 'Fantasy'),
(11, 'History'),
(12, 'Horror'),
(13, 'Music'),
(14, 'Musical'),
(15, 'Mystery'),
(16, 'TV Show '),
(17, 'Romance'),
(18, 'Sci-Fi'),
(19, 'Talk-Show'),
(20, 'Thriller'),
(21, 'War'),
(22, 'Western');
writers
CREATE TABLE IF NOT EXISTS writers
(id
bigint(20) NOT NULL AUTO_INCREMENT,name
varchar(500) NOT NULL,surname
varchar(500) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
writers
INSERT INTO writers
(id
, name
, surname
) VALUES
(1, 'Richard', 'Wenk'),
(2, 'Sylvester', 'Stallone'),
(3, 'Ken', 'Kaufman'),
(4, 'David', 'Agosto'),
(5, 'Dave', 'Callaham');
movies
CREATE TABLE IF NOT EXISTS movies
(id
bigint(12) NOT NULL AUTO_INCREMENT,title
varchar(500) NOT NULL,runningtime
varchar(10) NOT NULL,genre
varchar(125) NOT NULL,year
date NOT NULL,director
varchar(125) NOT NULL,writers
varchar(125) NOT NULL,actors
varchar(125) NOT NULL,description
text NOT NULL,storyline
longtext NOT NULL,image
varchar(250) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
movies
INSERT INTO movies
(id
, title
, runningtime
, genre
, year
, director
, writers
, actors
, description
, storyline
, image
) VALUES
(1, 'The Expendables 2', '103', '1,2,20', '2012-08-17', '1', '1,2,3,4,5', '1,2,3,4,5,6,7,8,9,10', 'Mr. Church reunites the Expendables for what should be an easy paycheck, but when one of their men is murdered on the job, their quest for revenge puts them deep in enemy territory and up against an unexpected threat.', 'Barney Ross is approached by CIA man Church, who wants him and his guns for hire to go to the former Soviet Union to retrieve something that was on a plane that crashed. Church doesn''t tell him what he is getting. And Church sends a woman, Maggie with him to make sure he gets it. They find the plane and get the thing but some men take one of Barney''s people hostage and the leader tells him to give him what they got or he''ll kill his hostage. The give it to him but he kills his hostage anyway. Barney asks Maggie what was so important about that thing. She says that it showed the location of a Russian plutonium storage mine. Barney decides to track the man down and deal with him. They track them down and discover that the man they seek is Vilain who leads a group known as The Sangs and that they have taken all the men from the surrounding villages to work the mine.', 'TheExpendables2.jpg');