Hi guys,
I have a problem with three tables i have. There are 3 tables, which contains a person name and its id, other tables contains a movie title, id for the movie and a person_id which is for director of the movie and relates to the first table, and the third table is for movie_id and the person_id that specifies which person of the first table plays in the film of the second table.
My big problem is that i can show the list of movies, but when it comes to search for the director it just show the director of the first movies and other field are blank. I got problem in resetting the fetch_assoc, for the first movie it searches for the director in the first table by using the person_id of second table, but after that it won't reset and so other fields will be blank.
this is my code:
<?php
require 'connect.php';
$mares = mysql_query ("
SELECT * FROM movie_actor
");
$mdres = mysql_query ("
SELECT * FROM movie
");
$pres = mysql_query ("
SELECT * FROM person
");
?>
<!doctype html>
<html>
<head>
<title>Show Details</title>
</head>
<body>
<table>
<tr>
<td width="40%">Film Title</td>
<td width="25%">Director Title</td>
<td width="25%">Actor Title</td>
<td width="25%">Role in the Movie</td>
</tr>
<?php while ($mdrow = mysql_fetch_assoc($mdres)) { ?>
<tr>
<td width="40%"><?php echo $mdrow['movie_title']; ?></td>
<?php while ($prow = mysql_fetch_assoc($pres)) { ?>
<td width="25%"><?php if ($mdrow['movie_person_id'] == $prow['person_id']) { ?>
<?php echo $prow['person_title']; ?>
<?php } ?></td>
</tr>
<?php } ?>
<?php } ?>
</table>
</body>
</html>
I'm at a total loss.
Could anyone please help me?
I have a problem with three tables i have. There are 3 tables, which contains a person name and its id, other tables contains a movie title, id for the movie and a person_id which is for director of the movie and relates to the first table, and the third table is for movie_id and the person_id that specifies which person of the first table plays in the film of the second table.
My big problem is that i can show the list of movies, but when it comes to search for the director it just show the director of the first movies and other field are blank. I got problem in resetting the fetch_assoc, for the first movie it searches for the director in the first table by using the person_id of second table, but after that it won't reset and so other fields will be blank.
this is my code:
<?php
require 'connect.php';
$mares = mysql_query ("
SELECT * FROM movie_actor
");
$mdres = mysql_query ("
SELECT * FROM movie
");
$pres = mysql_query ("
SELECT * FROM person
");
?>
<!doctype html>
<html>
<head>
<title>Show Details</title>
</head>
<body>
<table>
<tr>
<td width="40%">Film Title</td>
<td width="25%">Director Title</td>
<td width="25%">Actor Title</td>
<td width="25%">Role in the Movie</td>
</tr>
<?php while ($mdrow = mysql_fetch_assoc($mdres)) { ?>
<tr>
<td width="40%"><?php echo $mdrow['movie_title']; ?></td>
<?php while ($prow = mysql_fetch_assoc($pres)) { ?>
<td width="25%"><?php if ($mdrow['movie_person_id'] == $prow['person_id']) { ?>
<?php echo $prow['person_title']; ?>
<?php } ?></td>
</tr>
<?php } ?>
<?php } ?>
</table>
</body>
</html>
I'm at a total loss.
Could anyone please help me?
Comment