 |
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
 | This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 19th, 2011, 02:01 PM
|
|
Registered User
|
|
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chapter 4 - Page 114-115 ERROR
Chapter 4 - Page 114-115
In the following code below there is $type_id. I looked every where but could not find where $type_id is being assigned from. I also checked the database but didn't find any fields named type_id.
therefore this could very well be a mistake. Instead of $type_id, It should be
$movie_id
PHP Code:
< ?php
// take in the id of a director and return his/her full name
function get_director($director_id) {
global $db;
$query = âSELECT
people_fullname
FROM
people
WHERE
people_id = â . $director_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
// take in the id of a lead actor and return his/her full name
function get_leadactor($leadactor_id) {
global $db;
$query = âSELECT
people_fullname
FROM
people
WHERE
people_id = â . $leadactor_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
// take in the id of a movie type and return the meaningful textual
// description
function get_movietype($type_id) {
global $db;
$query = âSELECT
movietype_label
FROM
movietype
WHERE
movietype_id = â . $type_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $movietype_label;
}
//connect to MySQL
$db = mysql_connect(âlocalhostâ, âbp6amâ, âbp6ampassâ) or
die (âUnable to connect. Check your connection parameters.â);
// make sure youâre using the right database
mysql_select_db(âmoviesiteâ, $db) or die(mysql_error($db));
// retrieve information
$query = âSELECT
movie_name, movie_year, movie_director, movie_leadactor,
movie_type
FROM
movie
ORDER BY
movie_name ASC,
movie_year DESCâ;
$result = mysql_query($query, $db) or die(mysql_error($db));
// determine number of rows in returned result
$num_movies = mysql_num_rows($result);
$table = < < < ENDHTML
Part I: Movie Review Web Site
116
< div style=âtext-align: center;â >
< h2 > Movie Review Database < /h2 >
< table border=â1â cellpadding=â2â cellspacing=â2â
style=âwidth: 70%; margin-left: auto; margin-right: auto;â >
< tr >
< th > Movie Title < /th >
< th > Year of Release < /th >
< th > Movie Director < /th >
< th > Movie Lead Actor < /th >
< th > Movie Type < /th >
< /tr >
ENDHTML;
// loop through the results
while ($row = mysql_fetch_assoc($result)) {
extract($row);
$director = get_director($movie_director);
$leadactor = get_leadactor($movie_leadactor);
$movietype = get_movietype($movie_type);
$table .= < < < ENDHTML
< tr >
< td > $movie_name < /td >
< td > $movie_year < /td >
< td > $director < /td >
< td > $leadactor < /td >
< td > $movietype < /td >
< /tr >
ENDHTML;
}
$table .= < < < ENDHTML
< /table >
< p > $num_movies Movies < /p >
< /div >
ENDHTML;
echo $table
?>
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Chapter 4 pg 114 (Improving your Table) |
hozdaman |
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 |
1 |
September 5th, 2010 03:25 PM |
| Answer to the nightmare on pages 114, 115, 116, |
mobyme |
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 |
1 |
April 23rd, 2007 07:53 PM |
| Error: Chapter 3 (try it out) page 85 |
dea0303 |
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 |
0 |
August 29th, 2006 05:47 PM |
| Chapter 9 Try It Out Error, page 325 |
VictorVictor |
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 |
3 |
March 22nd, 2006 02:22 PM |
| Chapter 4 pg. 114-115 |
mjc2928 |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 |
4 |
August 25th, 2004 07:09 AM |
|
 |