Thanks for fast answer. I am totally new to php, thats why my code looks like a mess 🙂
I was trying to make something with heredoc by looking to an example(here it is, copying from pdf, it may look without formating):
<?php
$link = mysql_connect(“servername”,”username”,”userpassword”) or
die(mysql_error());
mysql_select_db(“wiley”) 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 align=’left’>Movie Title</th>
<th align=’left’>Movie Director</th>
<th align=’left’>Movie Lead Actor</th>
</tr>
EOD;
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;
Thats it, i do not see movie_details initialization before EOD, so thats why i havent made one too.. 🙂
I understand that using heredoc stores everything in a variable, and echo only prints out, but im not sure what i really need to use for adding information to the page.
Coding manner causes me big considerations too, because i dont know what is better, and how make things this way 🙂 Im using 'John Wiley & Sons - Beginning PHP, Apache, MySQL Web Develop' as the reference to enter php world 🙂