Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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.
Reply With Quote
  #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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:13 PM.


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