I am trying to show the result of my query but I am not getting any output from the php. I have tried several different loops but I cannot get anything to show on the page. The query works in PHPmyadmin and there are no errors showing when the webpage loads. This is the code. Let me know if you need any more information. I did print_r($data) and got this result :
mysqli_result Object ( [current_field] => 0 [field_count] => 8 [lengths] => [num_rows] => 2 [type] => 0 ) 2
$select = "SELECT u.`info_id`, u.`info`, u.`removed`, m.`date_added`, m.`title`, m.`summary`, m.`poster`, m.`imdb`, m.`cv` ".
"FROM `user_movies` AS u ".
"INNER JOIN `movies` AS m ".
"USING (`movie_id`) ".
"WHERE u.`user_id` = '{$_SESSION['user_id']}' ".
"AND u.`info` = '0' AND u.`removed` = '0' ".
"ORDER BY m.`date_added` DESC, m.`movie_id` ASC";
$data = mysqli_query($connect, $select) or die ('error getting user movies');
$movies = array();
while ($movie = mysqli_fetch_array($data));
{
array_push($movies, $movie);
}
foreach ($movies as $movie)
{
$id = str_replace(' ', '', $movie['title']);
$poster = $movie['poster'];
$title = $movie['title'];
$summary = $movie['summary'];
$imdb = $movie['imdb'];
echo "<div class='movie' id='$id'><img src='$poster' alt='$title' />" .
"<p><strong>$title</strong><br/>$summary<br/>" .
"<a href='$imdb'title='www.imdb.com'>More info at IMDb</a></p></div>";
}
$_SESSION['user_id']
is set correctly? – jeroen Mar 22 '12 at 22:00