
Oto kod plik movie_details.php
CODE
<?php /* Funkcja obliczająca czy film okazał się kasowym sukcesem czy raczej sromotna porażka */ function calculate_differences($takings, $cost) { $difference = $takings - $cost; if ($difference < 0) { $font_color = 'red' ; $profit_or_loss = "$" . $difference . "m"; } elseif ($difference > 0 ) { $font_color ='green' ; $profit_or_loss = "$" . $difference . "m"; } else { $font_color = 'blue' ; $profit_or_loss = "Równowaga"; } return "<font color=\"$font_color\">" . $profit_or_loss . "</font>"; } /*Funkcja pobierająca imię i nazwisko rezysera z tabeli people*/ function get_director() { $query_d = "SELECT people_fullname " . "FROM people " . "WHERE people_id ='$movie_director'"; $director = $people_fullname; } /*Funkcja pobierająca imię i nazwisko głównego aktora z tabeli people */ function get_leadactor() { $query_a = "SELECT people_fullname " . "FROM people " . "WHERE people_id='$movie_leadactor'"; $leadactor = $people_fullname; } function generate_ratings($review_rating) { $movie_rating = ''; for($i=0; $i<$review_rating; $i++){ $movie_rating .= "<img src=\"img\gwiazdka2.jpg\">$nbsp;"; } return $movie_rating; } $movie_query = "SELECT * FROM movie " . "WHERE movie_id = '" . $_GET['movie_id'] . "'"; $movie_table_headings=<<<EOD <tr> <th>Tytuł Filmu</th> <th>Rok produkcji</th> <th>Reżyser</th> <th>Główny Aktor</th> <th>Czas trwania</th> <th>Zysk lub strata</th> </tr> EOD; $review_table_headings=<<<EOD <tr> <th>Data wystawienia</th> <th>Tytuł recenzji</th> <th>Recenzent</th> <th>Treść recenzji</th> <th>Ocena</th> </tr> EOD; $review_flag =1; $review_title[] = $review_row['review_name']; $review[] = $review_row['review_comment']; $review_date[] = $review_row['review_date']; $review_rating = generate_ratings($review_row['review_rating']); } $i=0; $review_details = ''; while ($i<sizeof($review)){ $review_details .=<<<EOD <tr> <td width="15%" valign="top" align="center">$review_date[$i]</td> <td width="15%" valign="top">$review_title[$i]</td> <td width="10%" valign="top">$reviewe_name[$i]</td> <td width="50%" valign="top">$review[$i]</td> <td width="10%" valign="top" align="center">$review_rating[$i]</td> </tr> EOD; $i++; } $movie_name = $row['movie_name']; $movie_director = $row['movie_director']; $movie_leadactor = $row['movie_leadactor']; $movie_year = $row['movie_year']; $movie_running_time = $row['movie_running_time']." min."; $movie_takings = $row['movie_takings']; $movie_cost = $row['movie_cost']; //pobranie imienia i nazwiska rezysera z tabeli people get_director(); //pobranie imienia i nazwiska głównego aktora z tabeli people get_leadactor(); } $review_query = "SELECT * FROM reviews " . "WHERE review_movie_id ='" . $_GET['movie_id'] . "' " . "ORDER BY review_date DESC"; $movie_health = calculate_differences($movie_takings, $movie_cost); $page_start =<<<EOD <html> <head> <title>Szczegóły i recenzje dla: $movie_name</title> </head> <body> EOD; $movie_details =<<<EOD <table width="70%" border="0" cellspacing="2" cellpadding="2" align="center"> <tr> <th colspan="6"><u><h2>$movie_name: szczegóły</h2></u></th> </tr> $movie_table_headings <tr> <td width="33%" align="center">$movie_name</td> <td align="center">$movie_year</td> <td align="center">$director</td> <td align="center">$leadactor</td> <td align="center">$movie_running_time</td> <td align="center">$movie_health</td> </tr> </table> <br> <br> EOD; if ($review_flag) { $movie_details .=<<<EOD <table width="95%" border='0' cellspacing="2" cellpadding="20" align="center"> $review_table_headings $review_details </table> EOD; } $detailed_movie_info =<<<EOD $page_start $movie_details $page_end EOD; ?>