Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 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
  #1 (permalink)  
Old April 16th, 2007, 05:57 PM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Answer to the nightmare on pages 114, 115, 116,

You may like me have run into problems trying to populate your table following the code on pages 114, 115 and 116 only to find that the data doesn't finish up inside the table. In desperation you then download the code only to find nothing shows up at all. As far as I can establish the problem is due to white space here: $movie_header=<<<EOD and then some wrong coding for the table. It nearly drove me crazy so I thought the least I could do is post my solution. I hope it helps somebody else

<?php
$link = mysql_connect ("localhost", "root", "xxxxxx")
    or die(mysql_error());
mysql_select_db ("moviesite")
    or die(mysql_error());
$query = "SELECT movie_name, movie_director, movie_leadactor " .
                    "FROM movie";

$result = mysql_query($query, $link)
    or die(mysql_error());
$num_movies = mysql_num_rows($result);

$movie_header=<<<EOD
<h2><center>Movie Review Database</center></h2>
<table width="70%" border="1" cellpadding="2"
       cellspacing="2" align="center">
  <tr>
    <th>Movie Title</th>
    <th>Year of Release</th>
    <th>Movie Director</th>
  </tr>
EOD;
$movie_details = '';
while ($row = mysql_fetch_array($result)) {
  $movie_name = $row['movie_name'];
  $movie_director = $row['movie_director'];
  $movie_leadactor = $row['movie_leadactor'];

  $movie_details .=<<<EOD
  <tr>
    <td>$movie_name</td>
    <td>$movie_director</td>
    <td>$movie_leadactor</td>
  </tr>
EOD;
}

$movie_details .=<<<EOD
  <tr>
   <td> </td>
  </tr>
  <tr>
    <td>Total :$num_movies Movies</td>
  </tr>
EOD;
$movie_footer ="</table>";

$movie =<<<MOVIE
               $movie_header
               $movie_details
               $movie_footer
MOVIE;

  echo "There are $num_movies movies in our database";
  echo $movie;
?>

Best of luck and don't forget to repay the favour if you sort something out. We're all in this together.
  #2 (permalink)  
Old April 23rd, 2007, 07:53 PM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

updated code starting on line 38:

$movie_details .=<<<EOD
  <tr>
    <td>Total :$num_movies Movies</td>
  </tr>
EOD;
$movie_footer ="</table>";

//removes stray cell that was in previous post



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch. 4 pg114-116 chash BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 May 11th, 2006 11:36 AM
Template nightmare xgenerator Dreamweaver (all versions) 2 February 4th, 2005 03:24 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
Yet Another JavaScript Nightmare Ben Horne Javascript 3 October 15th, 2003 03:56 PM
Yet another insert nightmare. danielh Dreamweaver (all versions) 1 August 13th, 2003 09:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.