1. Sorry if have problem with my english, it's not so good.
2. I want to ask little help to understand one example from chapter 4 with replenishment information in tables.
The Example: table 2.php
Quote:
<?php
include("mysql_connect.php");
?>
<HEAD>
<TITLE>MYSQL TABLE</TITLE>
</HEAD>
<BODY>
<?php
mysql_select_db("moviesite");
$query = "SELECT movie_name, movie_director, movie_leadactor FROM movie";
$result = mysql_query($query) or die (mysql_error());
$num_movies = mysql_num_rows($result);
$movie_header =<<<EOD
<h2><center><b><i><font color=red> Страница за преглед на филми! </font color></b></i></center></h2>
<table width = "70%" border = "1" cellpadding = "2" cellspacing = "2" align = "center">
<tr>
<th bgcolor=#C2C2C2> Заглавие </th>
<th bgcolor=#C2C2C2> Режисьор </th>
<th bgcolor=#C2C2C2> Актьори </th>
</tr>
EOD;
//Функция за вземане на имената на директорите
function get_director() {
global $movie_director;
global $director;
$query_d = "SELECT people_fullname FROM people " .
"WHERE people_id = '$movie_director'";
$results_d = mysql_query($query_d) or die (mysql_error());
$row_d = mysql_fetch_array($results_d);
extract($row_d);
$director = $people_fullname;
}
// Функция за вземане на имената на артистите
function get_leadactor() {
global $movie_leadactor;
global $leadactor;
$query_a = "SELECT people_fullname FROM people " .
"WHERE people_id = '$movie_leadactor'";
$results_a = mysql_query($query_a) or die (mysql_error());
$row_a = mysql_fetch_array($results_a);
extract($row_a);
$leadactor = $people_fullname;
}
$movie_details = '';
while ($row = mysql_fetch_array($result)) {
$movie_name = $row['movie_name'];
$movie_director = $row['movie_director'];
$movie_leadactor = $row['movie_leadactor'];
get_director();
get_leadactor();
$movie_details .=<<<EOD
<tr>
<td bgcolor=eaeaea> $movie_name </td>
<td bgcolor=eaeaea> $director </td>
<td bgcolor=eaeaea> $leadactor </td>
</tr>
EOD;
}
$movie_details .=<<<EOD
<tr>
<td> </td>
</tr>
<tr>
<td> Всички филми са общо: $num_movies !</td>
</tr>
EOD;
$movie_footer = "</table>";
$movie =<<<EOD
$movie_header
$movie_details
$movie_footer
EOD;
echo "В нашата база има $num_movies филма";
echo $movie;
?>
</BODY>
|
My database is with different names of movie and actors, and different numbers of them, but structure is same as in the book!
End result not have errors, table in browser I have table with name of movie, directors and actors.
In column with moves, name of movies is these who must be.
In columns with director and actor is not the name who must be! Shuffle!
---
I try to find why and this and I get the funcions
function get_director() {
global $movie_director;
global $director;
$query_d = "SELECT people_fullname FROM people " .
"WHERE people_id = '$movie_director'";
...
}
and
function get_leadactor() {
global $movie_leadactor;
global $leadactor;
$query_a = "SELECT people_fullname FROM people " .
"WHERE people_id = '$movie_leadactor'";
...
}
In this function I understand, that the php get names from people_fullname from table people, and names are sent in $move_director/leadactor.
I can't understand how to php understand who is director and who is actor.
And my browser don't understand.
I think, that the results is send, without to look who is director or actor!
And How I understand who director is on who movie and his actors?
I make test with downloaded file from this site "table2.php.04": result is same!
May be I am in wrong somewhere!
From where I can post image?
http://bg-media.net/moviesite/table1.php
http://bg-media.net/moviesite/table2.php
if u import DB who is example in book - All seem Alright! If have make change in table "people" the result is not good!