( 3 , 2003-08-01 , An awesome time , George (Web hosting service) B. , I liked this movie,
( 3 , 2003-08-01 , An awesome time , George B. , I liked this movie, even though I thought it was an informational video from our travel agent. , 3 ) ; $insert_results = mysql_query($insert) or die(mysql_error()); ?> 2. Save this file as createreviews.php, upload it to your server, and open it in your browser. Your reviews table has now been created and filled! How It Works By now you should be familiar with creating tables using MySQL and PHP, and this should be pretty self-explanatory. If you re having trouble, you might try going back to Chapter 3. Try It Out Querying for the Reviews In this example, you re going to link two tables (movies and reviews) to show the reviews for a particular movie. This requires a lot of changes to the movie_details.php page, so you d best make a copy of the file (can t ever be too careful). Then follow these steps: 1. Open movie_details.php in your favorite text/HTML editor. 2. Make the following changes to the code (changes are highlighted): $movie_query = SELECT * FROM movie . WHERE movie_id = . $_GET[ movie_id ] . ; $movie_result = mysql_query($movie_query, $link) or die(mysql_error()); And later in the code, change the following: while ($row = mysql_fetch_array($movie_result)) { $movie_name = $row[ movie_name ]; $movie_director = $row[ movie_director ]; 3. Add the following lines after the closing bracket of your while statement: $review_query = SELECT * FROM reviews . WHERE review_movie_id = . $_GET[ movie_id ] . . ORDER BY review_date DESC ; $review_result = mysql_query($review_query, $link) or die(mysql_error()); How It Works You ve changed the name of $query to $movie_query, and also changed $result to $movie_result. This was done to ensure that you do not confuse yourself when accessing the relevant results set returned from a SQL query. There is also an order by clause, which ensures that the most recent reviews are at the top of the page. 130 Chapter 4
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services