$movie_header =<<
Movie Review Database
| Movie Title |
Movie Director |
Movie Lead Actor |
EOD; 4. Then enter the block of code that was originally there (minus the echo statement). Pay attention to the fact that it s called $movie_header, not $movie (as it was in the first example). $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 .=<<
| $movie_name |
$movie_director |
$movie_leadactor |
EOD; } $movie_details .=<<
| |
| Total :$num_movies Movies |
EOD; How It Works The preceding code does quite a lot of work for you, so let s look at it in more detail. As you know, the while { } statement loops through the records that have been returned. For each record, it executes the block of code that is between the brackets. Don t worry; PHP is smart enough to know how many records there are and what record number it is currently on in this case. There is no danger of having the wrong values assigned to the wrong record. The first line within the while loop tells the script to pull out the value of the field movie_name in the current record and put it into a variable called $movie_name. The next four lines do pretty much the same thing they simply assign different field values to differently named variables. 115 Using Tables to Display Data
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision php5 hosting services
This entry was posted
on Saturday, April 21st, 2007 at 3:02 am and is filed under php.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Leave a Reply