Wrox Programmer Forums

Need to download code?

View our list of code downloads.

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 Display Modes
  #11 (permalink)  
Old October 21st, 2010, 11:10 AM
Registered User
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey its ok, I found d error and fixed it and btw its not about alter this code, its abt everyone who start learning new php and sometime they get stuck somewhere and look for help. May be u have answered this question so many times but for beginners its still new, so think in that way.
Reply With Quote
  #12 (permalink)  
Old October 22nd, 2010, 06:07 AM
Registered User
 
Join Date: Oct 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by theSinthesizer View Post
Sup Guyz,

how much of this code are we allowed to alter?
Why are we using a "while loop" when we don't need it in pg 125 & 127.

I took it out and the code works just as well.

Do we keep it because we're going to use it later?

Here's my code:

PHP Code:
<?php
require ('includez/config.php');

/*Function to calculate if a movie made a profit, loss or broke even */
function calculate_differences($takings$cost) {
 
$difference $takings $cost;
 
 if (
$difference 0) {
  
$difference substr($difference1);
  
$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 "Broke even";
 }
 return 
"<font color=\"$font_color\">" $profit_or_loss "</font>";
}

/*Function to get the director's name from the people table*/
function get_director() {
 global 
$movie_director;
 global 
$director;
 
 
$query_d "SELECT people_fullname ".
             
"FROM people ".
             
"WHERE people_id='$movie_director'";
 
$result_d mysql_query($query_d) or die(mysql_error());
 
$row_d mysql_fetch_array($result_d);
 
extract($row_d);
 
$director $people_fullname;
}

/*Function to get the lead actor's name from the people's table*/
function get_leadactor() {
 global 
$movie_leadactor;
 global 
$leadactor;
 
 
$query_a "SELECT people_fullname ".
             
"FROM people ".
             
"WHERE people_id='$movie_leadactor'";
 
$result_a mysql_query($query_a) or die(mysql_error());
 
$row_a mysql_fetch_array($result_a);
 
extract($row_a);
 
$leadactor $people_fullname;
}

$query "SELECT * FROM movie ".
         
"WHERE movie_id='" $_GET['movie_id'] . "'";
$result mysql_query($query) or die(mysql_error());

$movie_table_headings=<<<EOD
<tr>
    <th>Movie Title</th>
    <th>Year of Release</th>
    <th>Movie Director</th>
    <th>Movie Lead Actor</th>
    <th>Movie Running Time</th>
    <th>Movie Health</th>
</tr>
EOD;

$row mysql_fetch_array($result);
//TOOK OUT THE WHILE LOOP HERE
$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']." mins";
$movie_takings $row['movie_takings'];
$movie_cost $row['movie_cost'];
 
 
//get director's name from people table
 
get_director();

 
//get lead actor's name from people table
 
get_leadactor();


$movie_health calculate_differences($movie_takings$movie_cost);
$page_start =<<<EOD
<html>
<head>
<title>Details and Reviews for: $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: Details</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;
$page_end =<<<EOD
</body>
</html>
EOD;
$detailed_movie_info =<<<EOD
$page_start
$movie_details
$page_end
EOD;

echo 
$detailed_movie_info;
mysql_close($link_id);
?>
Reply With Quote
  #13 (permalink)  
Old October 24th, 2010, 07:02 AM
Registered User
 
Join Date: Oct 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi guyz,

please can you tell me why my column sorting for exercise 2 doesn't work properly. My default sorting field is "review_date". After that, when I click on another column, it sorts by that column. But when I click another column, after that, it doesn't sort by that column.

Plz help!

Here's the relevant code:

Code:
$order = $_REQUEST['order'];

if (!$order) {
 $order = 'review_date';
 }

$review_query = "SELECT * FROM reviews ".
				"WHERE review_movie_id ='" . $_GET['movie_id'] . "' ".
				"ORDER BY $order";

$review_result = mysql_query($review_query) or die (mysql_error());

//these variables are created to make formating easier below.
$Page_Refresh = $_SERVER['PHP_SELF'];
$Movie_Id = $_GET['movie_id'];

$review_table_headings=<<<EOD
<tr>
	<th><a href="$Page_Refresh?movie_id=$Movie_Id&order='review_date'">Date of Review</a></th>
	<th><a href="$Page_Refresh?movie_id=$Movie_Id&order='review_name'">Review Title</a></th>
	<th><a href="$Page_Refresh?movie_id=$Movie_Id&order='review_reviewer_name'">Reviewer Name</a></th>
	<th><a href="$Page_Refresh?movie_id=$Movie_Id&order='review_comment'">Movie Review Comments</a></th>
	<th><a href="$Page_Refresh?movie_id=$Movie_Id&order='review_rating'">Rating</a></th>
</tr>
EOD;
Reply With Quote
Reply


Thread Tools
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
Chapter 1 - PHP installation issues Abelmiah BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 June 21st, 2009 06:01 PM
connection string issues, web.config file issues kaliaparijat ASP.NET 2.0 Professional 1 June 12th, 2008 09:07 AM
Chapter 4 P124 - movie_details Pheeal Beginning PHP 0 January 27th, 2006 10:16 AM
need help with movie_details.php code kjames1973 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 December 26th, 2004 04:28 PM
PHP installation issues, yet again donh BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 September 22nd, 2003 08:12 PM



All times are GMT -4. The time now is 05:38 PM.


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