newbreed65 Posted January 17, 2009 Share Posted January 17, 2009 Hey Everyone I'm having a problem with the movie part of the page the link will take you too. http://bulletsnoctane.co.uk/people/person.php?id=5 I'm trying to show all the movie that the person has been attached too but for some reason the first record in the query doesn't show it should be terminator salvation dark knight batman begins not just the last 2 movies, I've double checked the query in phpmyadmin and all 3 records show up <h3>Movies</h3> <?php $sql = "SELECT * FROM casts JOIN movie ON (casts.movie=movie.id) JOIN roles ON (casts.role=roles.id) WHERE person_id=" . $id . " ORDER BY released DESC"; $result = mysql_query($sql) or die(mysql_error()); $cast = mysql_fetch_array($result); if (mysql_num_rows($result) == 0) { echo " <em>currently not attached to any movies</em>"; $table = ""; } else { $table = "<table>"; while ($cast = mysql_fetch_array($result)) { $date1 = $cast['released']; $date2 = explode("-",date("Y-m-d",strtotime($date1)));//splits up the date $table .= "<tr><td>" . $date2[0] . "</td>" . '<td><a href="/movies/movie.php?id=' . $cast['movie'] . '">' . $cast['name'] . "</a></td><td>" . $cast['role_name'] . "</td><td>" . $cast['char_name'] . "</td>"; } } $table .= "</table>"; echo $table; ?> </div> Link to comment https://forums.phpfreaks.com/topic/141242-solved-the-first-of-records-my-query-isnt-showing-up/ Share on other sites More sharing options...
DeanWhitehouse Posted January 17, 2009 Share Posted January 17, 2009 Try deleting $cast = mysql_fetch_array($result); (the one before the loop) To explain, here you are reading the first row from the table and placing the pointer there then in the loop you are looping through all the rows starting one after the pointer. Link to comment https://forums.phpfreaks.com/topic/141242-solved-the-first-of-records-my-query-isnt-showing-up/#findComment-739281 Share on other sites More sharing options...
newbreed65 Posted January 17, 2009 Author Share Posted January 17, 2009 ah thank you didnt notice that Link to comment https://forums.phpfreaks.com/topic/141242-solved-the-first-of-records-my-query-isnt-showing-up/#findComment-739283 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.