Fine tuning a films database

I have a working php/mysql database to show/search my films collection.
When I call for a php page with all the films of an actor I see, as actor, only that actor, and not the other ones.
I’d like to see also the others, as is in the main film page.

This is the code:

the main page

<?php 

$sql = "SELECT 
  f.mov_id
, f.titolo
, f.titolo_italiano
, f.imagelink
, f.regia
, f.regia_nome
, f.data
, f.contenuti
, f.genere
, f.keywords
, c.act_id	
, c.role
, c.mov_reg_id
, e.id AS 'act_id'
, e.evento AS 'cognome'
, e.`evento.spec` AS 'nome'
, e.data AS 'act_data'
, e.data_fine AS 'act_data_morte'
, e.imagelink AS 'act_imagelink'
FROM `films__olon` f
	LEFT JOIN `films__cast` c 
		ON c.mov_id = f.mov_id
	LEFT JOIN `eventi` e 
		ON e.id = c.act_id
	LEFT JOIN `films__registi` r 
		ON r.id = c.mov_reg_id	
WHERE f.genere LIKE '%$genere%'
ORDER by f.data"; 

$data=array();
$query = $pdo->prepare($sql);	
$query->execute();
while($row = $query->fetch(PDO::FETCH_ASSOC)){

	$data[$row['mov_id']]['movie']['mov_id'] = $row['mov_id'];
	$data[$row['mov_id']]['movie']['titolo'] = $row['titolo'];
	$data[$row['mov_id']]['movie']['titolo_italiano'] = $row['titolo_italiano'];
	$data[$row['mov_id']]['movie']['imagelink'] = $row['imagelink'];
	$data[$row['mov_id']]['movie']['regia'] = $row['regia'];
	$data[$row['mov_id']]['movie']['regia_nome'] = $row['regia_nome'];
	$data[$row['mov_id']]['movie']['reg_id'] = $row['mov_reg_id'];
	$data[$row['mov_id']]['movie']['data'] = $row['data'];
	$data[$row['mov_id']]['movie']['contenuti'] = $row['contenuti'];
	$data[$row['mov_id']]['movie']['keywords'] = $row['keywords'];
	
	$data[$row['mov_id']]['genere'][$row['genere']] = $row['genere'];
	
	if(!empty($row['act_id'])):
		$data[$row['mov_id']]['cast'][$row['act_id']]['act_id'] = $row['act_id'];
		$data[$row['mov_id']]['cast'][$row['act_id']]['role'] = $row['role'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['cognome'] = $row['cognome'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['nome'] = $row['nome'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['data'] = $row['act_data'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['data_fine'] = $row['act_data_morte'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['imagelink'] = $row['act_imagelink'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['mov_reg_id'] = $row['mov_reg_id'];
	endif;
}
?>

<?php

if(!empty($data)):
	foreach($data as $mov_id => $arr): 
	
		// People details
		if(!empty($_GET['people']) && array_key_exists($_GET['people'],$data[$mov_id]['cast'])):
		
			echo '<h2>'.$data[$mov_id]['cast'][$_GET['people']]['nome'].' '.$data[$mov_id]['cast'][$_GET['people']]['cognome'].'<br />'."\r";		
				if(!empty($data[$mov_id]['cast'][$_GET['people']]['imagelink'])):
					echo '<img src="'.$data[$mov_id]['cast'][$_GET['people']]['imagelink'].'" height="200px" class="fr">'."\r";
				endif;
			echo '</h2><blockquote style="width:50%;">'.$data[$mov_id]['cast'][$_GET['people']]['data'].'<br /><a href="film.new.php">Close</a></blockquote>'."\r";
		
		endif;   
		
		//Basic display
		echo '<h2><span class="tooltip"><span class="tooltiptext">'.$data[$mov_id]['movie']['titolo_italiano'].' - '.$data[$mov_id]['movie']['mov_id'].'</span>'.$data[$mov_id]['movie']['titolo'].'</span>'."\r";		
			if(!empty($data[$mov_id]['movie']['imagelink'])):
				echo '<img src="'.$data[$mov_id]['movie']['imagelink'].'" height="200px" class="fr" alt="'.$data[$mov_id]['movie']['titolo'].'" />'."\r";
			endif;
		echo '</h2>
		<p>data: <b>'.$data[$mov_id]['movie']['data'].'</b> - regista: '.$data[$mov_id]['movie']['regia_nome'].' <span class="tooltip"><span class="tooltiptext">'.$data[$mov_id]['movie']['reg_id'].'</span> <a href="hashtag-registi.php?tag='.$data[$mov_id]['movie']['regia'].'&amp;mode=regia">'.$data[$mov_id]['movie']['regia'].'</a></span></p>
		<blockquote><p>'.$data[$mov_id]['movie']['contenuti'].'</p></blockquote>'."\n";
		
		//attori
		if(!empty($data[$mov_id]['cast'])):
			echo '<p class="cast"><b>attori</b>: ';
			foreach($data[$mov_id]['cast'] as $actor_id => $cast):
			   echo '<span class="tooltip">
			    <span class="tooltiptext"><img src="' .$cast['imagelink'].'" alt="'.$cast['cognome'].'" />
			    (' .$cast['data'].' / ' .$cast['data_fine'].')</span>
			    <a href="hashtag-actors.php?tag='.$cast['act_id'].'&amp;mode=act">'.$cast['nome'].' '.$cast['cognome']. '</a></span>
			    <span class="as">(as ' .$cast['role']. ')</span> '; 
			endforeach;
			echo '</p>'."\n";
		endif;
		
		//keywords
		$keywords = $data[$mov_id]['movie']['keywords'];
			if(!empty($data[$mov_id]['movie']['keywords'])):
			echo "	<p class=\"keywords\"><b>temi</b>:";	
			foreach (explode(',', $keywords) as $key): 
				echo "<span><a href=\"hashtag-keywords.php?tag=$key&amp;mode=libere\">{$key}</a></span>";
			endforeach;
			echo "</p>";
			endif;
	endforeach;
endif;
?>

for hashtags

<?php  
 //hashtag.php  
 if(isset($_GET["tag"]))  
 {  
	 $_GET['tag'] = (!empty($_GET['tag']) ? preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', '', $_GET['tag']) : '');
	 $tag = preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', '', $_GET['tag']); 

$sql = "SELECT 
 CONCAT(se.evento,' ',se.`evento.spec`) as '$keyspec'
, f.mov_id
, f.titolo
, f.titolo_italiano
, f.imagelink
, f.regia
, f.regia_nome
, f.data
, f.contenuti
, f.genere
, f.keywords
, c.act_id	
, c.role
, e.id AS 'act_id'
, e.evento AS 'cognome'
, e.`evento.spec` AS 'nome'
, e.data AS 'act_data'
, e.data_fine AS 'act_data_morte'
, e.imagelink AS 'act_imagelink'
FROM `films__cast` sc 	
	LEFT JOIN `eventi` se 
		ON se.id = sc.act_id
	LEFT JOIN `films__cast` c 
		ON c.mov_id = sc.mov_id	
	LEFT JOIN `eventi` e 
		ON e.id = c.act_id
	LEFT JOIN `films__olon` f
		ON f.mov_id = c.mov_id
WHERE $specifico LIKE  '%".$tag."%'
ORDER by f.data"; 


$data=array();
$query = $pdo->prepare($sql);	
$query->execute();
while($row = $query->fetch(PDO::FETCH_ASSOC)){

	$data[$row['mov_id']]['movie']['mov_id'] = $row['mov_id'];
	$data[$row['mov_id']]['movie']['titolo'] = $row['titolo'];
	$data[$row['mov_id']]['movie']['titolo_italiano'] = $row['titolo_italiano'];
	$data[$row['mov_id']]['movie']['imagelink'] = $row['imagelink'];
	$data[$row['mov_id']]['movie']['regia'] = $row['regia'];
	$data[$row['mov_id']]['movie']['regia_nome'] = $row['regia_nome'];
	$data[$row['mov_id']]['movie']['data'] = $row['data'];
	$data[$row['mov_id']]['movie']['contenuti'] = $row['contenuti'];
	$data[$row['mov_id']]['movie']['keywords'] = $row['keywords'];
	
	$data[$row['mov_id']]['genere'][$row['genere']] = $row['genere'];
				
	$actor = "$row[nome] $row[cognome]"; 
	$libere = $row['keywords']; 
	$regia = "$row[regia_nome] $row[regia]"; 
	
	if(!empty($row['act_id'])):
		$data[$row['mov_id']]['cast'][$row['act_id']]['act_id'] = $row['act_id'];
		$data[$row['mov_id']]['cast'][$row['act_id']]['role'] = $row['role'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['cognome'] = $row['cognome'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['nome'] = $row['nome'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['data'] = $row['act_data'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['data_fine'] = $row['act_data_morte'];
		$data[$row['mov_id']]['cast'][$row['act_id']]['imagelink'] = $row['act_imagelink'];
	endif;
}

$mode = (!empty($_GET['mode']) ? $_GET['mode'] : ''); 
switch ($mode) {
    case "act":
        $title = $actor;
        break;
    case "libere":       
        //$title = $libere;
		$title = $tag;
        break;
    case "regia":
        $title = $regia;
        break;
    default:
       //$title =  $regia;
	   $title =  "Mode not defined"; 
		//$title = $tag;
}
    include "$root/intell/header-intell.inc";  
?>


<?php        

if(!empty($data)):
	foreach($data as $mov_id => $arr): 
         
		// People details
		if(!empty($_GET['people']) && array_key_exists($_GET['people'],$data[$mov_id]['cast'])):
		
			echo '<h2>'.$data[$mov_id]['cast'][$_GET['people']]['nome'].' '.$data[$mov_id]['cast'][$_GET['people']]['cognome'].'<br />'."\r";		
				if(!empty($data[$mov_id]['cast'][$_GET['people']]['imagelink'])):
					echo '<img src="'.$data[$mov_id]['cast'][$_GET['people']]['imagelink'].'" height="200px" class="fr">'."\r";
				endif;
			echo '</h2><blockquote style="width:50%;">'.$data[$mov_id]['cast'][$_GET['people']]['data'].'<br /><a href="film.new.php">Close</a></blockquote>'."\r";
		
		endif;   
		
		//Basic display
		echo '<h2>'.$data[$mov_id]['movie']['titolo'].'<br />'."\r";		
			if(!empty($data[$mov_id]['movie']['imagelink'])):
				echo '<img src="'.$data[$mov_id]['movie']['imagelink'].'" height="200px" class="fr" alt="'.$data[$mov_id]['movie']['titolo'].'" />'."\r";
			endif;
		echo '</h2>
		<p>data: <b>'.$data[$mov_id]['movie']['data'].'</b> - regista: '.$data[$mov_id]['movie']['regia_nome'].' <a href="hashtag-registi.php?tag='.$data[$mov_id]['movie']['regia'].'&amp;mode=regia">'.$data[$mov_id]['movie']['regia'].'</a></p>
		<blockquote><p>'.$data[$mov_id]['movie']['contenuti'].'</p></blockquote>'."\n";
		
		//attori
		if(!empty($data[$mov_id]['cast'])):
			echo '<p class="cast"><b>attori</b>: ';
			foreach($data[$mov_id]['cast'] as $actor_id => $cast):
			   echo '<span class="tooltip">
			    <span class="tooltiptext"><img src="' .$cast['imagelink'].'" alt="'.$cast['cognome'].'" />
			    (' .$cast['data'].' / ' .$cast['data_fine'].')</span>
			    <a href="hashtag-actors.php?tag='.$cast['act_id'].'&amp;mode=act">'.$cast['nome'].' '.$cast['cognome']. '</a></span>
			    <span class="as">(as ' .$cast['role']. ')</span> '; 
			endforeach;
			echo '</p>'."\n";
		endif;
		
		//keywords
		$keywords = $data[$mov_id]['movie']['keywords'];
			if(!empty($data[$mov_id]['movie']['keywords'])):
			echo "	<p class=\"keywords\"><b>temi</b>:";	
			foreach (explode(',', $keywords) as $key): 
				echo "<span><a href=\"hashtag-keywords.php?tag=$key&amp;mode=libere\">{$key}</a></span>";
			endforeach;
			echo "</p>";
			endif;
	endforeach;
endif;
 }
?>

When I click on a keyword or a director (“regia”) I see all the actors of a film. But when I click an actor aI see a list of the films with only that actor.

I add an html output:

<h2>Star Wars.4  A new hope<br />
<img src="my-image.jpg" height="200px" class="fr" alt="Star Wars.4  A new hope" />
</h2>
		<p>data: <b>1977</b> - regista: George <a href="hashtag-registi.php?tag=Lucas&amp;mode=regia">Lucas</a></p>
		<blockquote><p>[...]</p></blockquote>
<p class="cast"><b>attori</b>: <span class="tooltip">
			    <span class="tooltiptext"><img src="http://localhost/img/ritratti/Hamill, Mark.jpg" alt="Hamill" />
			    (1951 / )</span>
			    <a href="hashtag-actors.php?tag=1377&amp;mode=act">Mark Hamill</a></span>
			    <span class="as">(as Luke Skywalker)</span> </p>
	<p class="keywords"><b>temi</b>:<span><a href="hashtag-keywords.php?tag=lotta bene/male&amp;mode=libere">lotta bene/male</a></span><span><a href="hashtag-keywords.php?tag=star wars&amp;mode=libere">star wars</a></span></p>

the same film, in the main page

(I add only the most important selection: the actors)

<p class="cast"><b>attori</b>: <span class="tooltip">
			    <span class="tooltiptext"><img src="http://localhost/img/ritratti/Hamill, Mark.jpg" alt="Hamill" />
			    (1951 / )</span>
			    <a href="hashtag-actors.php?tag=1377&amp;mode=act">Mark Hamill</a></span>
			    <span class="as">(as Luke Skywalker)</span> <span class="tooltip">
			    <span class="tooltiptext"><img src="http://localhost/img/ritratti/Ford, Harrison.jpg" alt="Ford" />
			    (1942 / )</span>
			    <a href="hashtag-actors.php?tag=1344&amp;mode=act">Harrison Ford</a></span>
			    <span class="as">(as Ian Solo)</span> </p>

Thank you!

There is some further info I should provide?
Thank you!

Split your question into 2. SQL and PHP. Gives your SQL query correct answer?

1 Like

Uhm… I’m not sure: both seems work…
But probably the problem is sql.

I guess that the code to modify is this (from my code above reported):

		if(!empty($data[$mov_id]['cast'])):
			echo '<p class="cast"><b>attori</b>: ';
			foreach($data[$mov_id]['cast'] as $actor_id => $cast):
			   echo '<span class="tooltip">
			    <span class="tooltiptext"><img src="' .$cast['imagelink'].'" alt="'.$cast['cognome'].'" />
			    (' .$cast['data'].' / ' .$cast['data_fine'].')</span>
			    <a href="hashtag-actors.php?tag='.$cast['act_id'].'&amp;mode=act">'.$cast['nome'].' '.$cast['cognome']. '</a></span>
			    <span class="as">(as ' .$cast['role']. ')</span> '; 
			endforeach;
			echo '</p>'."\n";
		endif;

In particular this

		`foreach($data[$mov_id]['cast'] as $actor_id => $cast):`

I am not a big expert in mysql language, but I guess that that code select only one actor.

Maybe i’m confused by your description of your intended User Experience.

You want a user to be able to click on an Actor’s name and get… the list of all movies? Not the movies that actor has been in?

That feels counterintuitive…

1 Like

Of course, no: the list of all the movies that actor was been in. But in that list, I’d like to get, as actors, even the other actors of that movies.
I mean:

this is what I see when I click on Stan Laurel

[it is only a piece]

and this is what I’d like see (and I can see clicking on a director)

[also here: only a piece]

More elegantly… without shorthand code:

<?php 

$sql = "SELECT 
	f.mov_id,
	f.titolo,
	f.titolo_italiano,
	f.imagelink,
	f.regia,
	f.regia_nome,
	f.data,
	f.contenuti,
	f.genere,
	f.keywords,
	c.act_id,
	c.role,
	c.mov_reg_id,
	e.id AS 'act_id',
	e.evento AS 'cognome',
	e.`evento.spec` AS 'nome',
	e.data AS 'act_data',
	e.data_fine AS 'act_data_morte',
	e.imagelink AS 'act_imagelink'
FROM `films__olon` f
	LEFT JOIN `films__cast` c 
		ON c.mov_id = f.mov_id
	LEFT JOIN `eventi` e 
		ON e.id = c.act_id
	LEFT JOIN `films__registi` r 
		ON r.id = c.mov_reg_id	
WHERE f.genere LIKE '%$genere%'
ORDER BY f.data"; 

$data = array();
$query = $pdo->prepare($sql);	
$query->execute();

while ($row = $query->fetch(PDO::FETCH_ASSOC)) {

	$data[$row['mov_id']]['movie']['mov_id'] = $row['mov_id'];
	$data[$row['mov_id']]['movie']['titolo'] = $row['titolo'];
	$data[$row['mov_id']]['movie']['titolo_italiano'] = $row['titolo_italiano'];
	$data[$row['mov_id']]['movie']['imagelink'] = $row['imagelink'];
	$data[$row['mov_id']]['movie']['regia'] = $row['regia'];
	$data[$row['mov_id']]['movie']['regia_nome'] = $row['regia_nome'];
	$data[$row['mov_id']]['movie']['reg_id'] = $row['mov_reg_id'];
	$data[$row['mov_id']]['movie']['data'] = $row['data'];
	$data[$row['mov_id']]['movie']['contenuti'] = $row['contenuti'];
	$data[$row['mov_id']]['movie']['keywords'] = $row['keywords'];
	
	$data[$row['mov_id']]['genere'][$row['genere']] = $row['genere'];
	
	if (!empty($row['act_id'])) {
		$data[$row['mov_id']]['cast'][$row['act_id']]['act_id'] = $row['act_id'];
		$data[$row['mov_id']]['cast'][$row['act_id']]['role'] = $row['role'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['cognome'] = $row['cognome'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['nome'] = $row['nome'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['data'] = $row['act_data'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['data_fine'] = $row['act_data_morte'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['imagelink'] = $row['act_imagelink'];	
		$data[$row['mov_id']]['cast'][$row['act_id']]['mov_reg_id'] = $row['mov_reg_id'];
	}
}
?>
<?php

if (!empty($data)) {
	foreach ($data as $mov_id => $arr) { 
	
		// People details
		if (!empty($_GET['people']) && array_key_exists($_GET['people'], $data[$mov_id]['cast'])) {
		
			echo '<h2>' . $data[$mov_id]['cast'][$_GET['people']]['nome'] . ' ' . $data[$mov_id]['cast'][$_GET['people']]['cognome'] . '<br />' . "\r";		
			if (!empty($data[$mov_id]['cast'][$_GET['people']]['imagelink'])) {
				echo '<img src="' . $data[$mov_id]['cast'][$_GET['people']]['imagelink'] . '" height="200px" class="fr">' . "\r";
			}
			echo '</h2><blockquote style="width:50%;">' . $data[$mov_id]['cast'][$_GET['people']]['data'] . '<br /><a href="film.new.php">Close</a></blockquote>' . "\r";
		
		}   
		
		// Basic display
		echo '<h2><span class="tooltip"><span class="tooltiptext">' . $data[$mov_id]['movie']['titolo_italiano'] . ' - ' . $data[$mov_id]['movie']['mov_id'] . '</span>' . $data[$mov_id]['movie']['titolo'] . '</span>' . "\r";		
		if (!empty($data[$mov_id]['movie']['imagelink'])) {
			echo '<img src="' . $data[$mov_id]['movie']['imagelink'] . '" height="200px" class="fr" alt="' . $data[$mov_id]['movie']['titolo'] . '" />' . "\r";
		}
		echo '</h2>
		<p>data: <b>' . $data[$mov_id]['movie']['data'] . '</b> - regista: ' . $data[$mov_id]['movie']['regia_nome'] . ' <span class="tooltip"><span class="tooltiptext">' . $data[$mov_id]['movie']['reg_id'] . '</span> <a href="hashtag-registi.php?tag=' . $data[$mov_id]['movie']['regia'] . '&amp;mode=regia">' . $data[$mov_id]['movie']['regia'] . '</a></span></p>
		<blockquote><p>' . $data[$mov_id]['movie']['contenuti'] . '</p></blockquote>' . "\n";
		
		// Actors
		if (!empty($data[$mov_id]['cast'])) {
			echo '<p class="cast"><b>attori</b>: ';
			foreach ($data[$mov_id]['cast'] as $actor_id => $cast) {
				echo '<span class="tooltip">
					<span class="tooltiptext"><img src="' . $cast['imagelink'] . '" alt="' . $cast['cognome'] . '" />
					(' . $cast['data'] . ' / ' . $cast['data_fine'] . ')</span>
					<a href="hashtag-actors.php?tag=' . $cast['act_id'] . '&amp;mode=act">' . $cast['nome'] . ' ' . $cast['cognome'] . '</a></span>
					<span class="as">(as ' . $cast['role'] . ')</span> '; 
			}
			echo '</p>' . "\n";
		}
		
		// Keywords
		$keywords = $data[$mov_id]['movie']['keywords'];
		if (!empty($data[$mov_id]['movie']['keywords'])) {
			echo '<p class="keywords"><b>temi</b>:';
			foreach (explode(',', $keywords) as $key) { 
				echo '<span><a href="hashtag-keywords.php?tag=' . $key . '&amp;mode=libere">' . $key . '</a></span>';
			}
			echo '</p>';
		}
	}
}
?>
<?php  
if (isset($_GET["tag"])) {  
	$_GET['tag'] = (!empty($_GET['tag']) ? preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', '', $_GET['tag']) : '');
	$tag = preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', '', $_GET['tag']); 

	$sql = "SELECT 
		CONCAT(se.evento, ' ', se.`evento.spec`) AS 'keyspec',
		f.mov_id,
		f.titolo,
		f.titolo_italiano,
		f.imagelink,
		f.regia,
		f.regia_nome,
		f.data,
		f.contenuti,
		f.genere,
		f.keywords,
		c.act_id,
		c.role,
		e.id AS 'act_id',
		e.evento AS 'cognome',
		e.`evento.spec` AS 'nome',
		e.data AS 'act_data',
		e.data_fine AS 'act_data_morte',
		e.imagelink AS 'act_imagelink'
	FROM `films__cast` sc 	
		LEFT JOIN `eventi` se 
			ON se.id = sc.act_id
		LEFT JOIN `films__cast` c 
			ON c.mov_id = sc.mov_id	
		LEFT JOIN `eventi` e 
			ON e.id = c.act_id
		LEFT JOIN `films__olon` f
			ON f.mov_id = c.mov_id
	WHERE $specifico LIKE '%" . $tag . "%'
	ORDER BY f.data"; 

	$data = array();
	$query = $pdo->prepare($sql);	
	$query->execute();

	while ($row = $query->fetch(PDO::FETCH_ASSOC)) {

		$data[$row['mov_id']]['movie']['mov_id'] = $row['mov_id'];
		$data[$row['mov_id']]['movie']['titolo'] = $row['titolo'];
		$data[$row['mov_id']]['movie']['titolo_italiano'] = $row['titolo_italiano'];
		$data[$row['mov_id']]['movie']['imagelink'] = $row['imagelink'];
		$data[$row['mov_id']]['movie']['regia'] = $row['regia'];
		$data[$row['mov_id']]['movie']['regia_nome'] = $row['regia_nome'];
		$data[$row['mov_id']]['movie']['data'] = $row['data'];
		$data[$row['mov_id']]['movie']['contenuti'] = $row['contenuti'];
		$data[$row['mov_id']]['movie']['keywords'] = $row['keywords'];
		
		$data[$row['mov_id']]['genere'][$row['genere']] = $row['genere'];
		
		if (!empty($row['act_id'])) {
			$data[$row['mov_id']]['cast'][$row['act_id']]['act_id'] = $row['act_id'];
			$data[$row['mov_id']]['cast'][$row['act_id']]['role'] = $row['role'];	
			$data[$row['mov_id']]['cast'][$row['act_id']]['cognome'] = $row['cognome'];	
			$data[$row['mov_id']]['cast'][$row['act_id']]['nome'] = $row['nome'];	
			$data[$row['mov_id']]['cast'][$row['act_id']]['data'] = $row['act_data'];	
			$data[$row['mov_id']]['cast'][$row['act_id']]['data_fine'] = $row['act_data_morte'];	
			$data[$row['mov_id']]['cast'][$row['act_id']]['imagelink'] = $row['act_imagelink'];	
			$data[$row['mov_id']]['cast'][$row['act_id']]['mov_reg_id'] = $row['mov_reg_id'];
		}
	}
}

?>
<?php

if (!empty($data)) {
	foreach ($data as $mov_id => $arr) { 
	
		// People details
		if (!empty($_GET['people']) && array_key_exists($_GET['people'], $data[$mov_id]['cast'])) {
		
			echo '<h2>' . $data[$mov_id]['cast'][$_GET['people']]['nome'] . ' ' . $data[$mov_id]['cast'][$_GET['people']]['cognome'] . '<br />' . "\r";		
			if (!empty($data[$mov_id]['cast'][$_GET['people']]['imagelink'])) {
				echo '<img src="' . $data[$mov_id]['cast'][$_GET['people']]['imagelink'] . '" height="200px" class="fr">' . "\r";
			}
			echo '</h2><blockquote style="width:50%;">' . $data[$mov_id]['cast'][$_GET['people']]['data'] . '<br /><a href="film.new.php">Close</a></blockquote>' . "\r";
		
		}   
		
		// Basic display
		echo '<h2><span class="tooltip"><span class="tooltiptext">' . $data[$mov_id]['movie']['titolo_italiano'] . ' - ' . $data[$mov_id]['movie']['mov_id'] . '</span>' . $data[$mov_id]['movie']['titolo'] . '</span>' . "\r";		
		if (!empty($data[$mov_id]['movie']['imagelink'])) {
			echo '<img src="' . $data[$mov_id]['movie']['imagelink'] . '" height="200px" class="fr" alt="' . $data[$mov_id]['movie']['titolo'] . '" />' . "\r";
		}
		echo '</h2>
		<p>data: <b>' . $data[$mov_id]['movie']['data'] . '</b> - regista: ' . $data[$mov_id]['movie']['regia_nome'] . ' <span class="tooltip"><span class="tooltiptext">' . $data[$mov_id]['movie']['reg_id'] . '</span> <a href="hashtag-registi.php?tag=' . $data[$mov_id]['movie']['regia'] . '&amp;mode=regia">' . $data[$mov_id]['movie']['regia'] . '</a></span></p>
		<blockquote><p>' . $data[$mov_id]['movie']['contenuti'] . '</p></blockquote>' . "\n";
		
		// Actors
		if (!empty($data[$mov_id]['cast'])) {
			echo '<p class="cast"><b>attori</b>: ';
			foreach ($data[$mov_id]['cast'] as $actor_id => $cast) {
				echo '<span class="tooltip">
					<span class="tooltiptext"><img src="' . $cast['imagelink'] . '" alt="' . $cast['cognome'] . '" />
					(' . $cast['data'] . ' / ' . $cast['data_fine'] . ')</span>
					<a href="hashtag-actors.php?tag=' . $cast['act_id'] . '&amp;mode=act">' . $cast['nome'] . ' ' . $cast['cognome'] . '</a></span>
					<span class="as">(as ' . $cast['role'] . ')</span> '; 
			}
			echo '</p>' . "\n";
		}
		
		// Keywords
		$keywords = $data[$mov_id]['movie']['keywords'];
		if (!empty($data[$mov_id]['movie']['keywords'])) {
			echo '<p class="keywords"><b>temi</b>:';
			foreach (explode(',', $keywords) as $key) { 
				echo '<span><a href="hashtag-keywords.php?tag=' . $key . '&amp;mode=libere">' . $key . '</a></span>';
			}
			echo '</p>';
		}
	}
}
?>

Thank you, but unfortunately your code doesn’t work (no result at all).

It is a general snippet to show you “about how” to do it. You’re not supposed to just take it and copy and paste, you are supposed to know how to code already of you are here. I’m not getting paying to do it, so I’m not gonna sit here spending my whole day making something work.

1 Like