TheMovieman Posted October 6, 2007 Posted October 6, 2007 I'm sure this is a dumb mistake on my part (it's been some time since I've coded a join), but I've been having problems with this latest one. I'm making a page to display all my reviews that pertain to a single studio. For example, when one types in ****/index.php?id=1, it'll take you to "Warner Bros." and it will list all the reviews associated with Warner Bros. Here's how I have my tables set up, with the column names pertaining to this code: dvd_reviews (id, title, year) studio (id, name) moviestudio (movieid, studioid) I have a $_GET function for the studio id and everything on the page works fine as far as getting the Studio Name in the places I want it. Here's what I've been trying: > <?php $movietitles = @mysql_query("SELECT title, year, dvd_reviews.id, movieid, studioid FROM dvd_reviews, moviestudio WHERE studioid='$id' AND movieid=dvd_reviews.id"); if (!$movietitles) { exit('<p>Error retrieving information from database.<br />'. 'Error: ' . mysql_error() . '</p>'); } while ($title-dvd = mysql_fetch_array($movietitles)) { $dvdtitle = $title-dvd['title']; $year = $title-dvd['year']; echo "<tr><td>$dvdtitle ($year)</td></tr>" } ?> I've tried other variations on that but get a parse error everytime: "Parse error: syntax error, unexpected '=' in /home2/*removed*/public_html/studios/index.php on line 114" I know I'm missing something, but I can't figure out what. Thanks in advance Brian Quote
TheMovieman Posted October 6, 2007 Author Posted October 6, 2007 And I know I missed a " ; " at the end of the echo statement. I've put it in and still get the parse error. Quote
TheMovieman Posted October 6, 2007 Author Posted October 6, 2007 (edited) Edit: Nevermind. Somehow fixed it... Dunno what happened but I redid the code and now it works. Edit #2: Now I've come across another problem. Even though the data displays fine, when I try to add a link, I can't get the dvd_reviews.id to pass through to a variable. Here's how I have it set up now: ><?php $movielist = @mysql_query("SELECT title, year, movieid, studioid, dvd_reviews.id, studio.id FROM dvd_reviews, studio, moviestudio WHERE movieid=dvd_reviews.id AND studioid='$id' AND studio.id='$id'"); if (!$movielist) { exit('<p>Error retrieving information from database.<br />'. 'Error: ' . mysql_error() . '</p>'); } while ($listing = mysql_fetch_array($movielist)) { $title = $listing['title']; $year = $listing['year']; $dvdlink = $listing['dvd_reviews.id']; echo "<tr><td><a href='http://www.moviemansguide.com/reviews/DVD/read.php? id=$dvdlink'>$title</a></td><td>$year</td></tr>"; } ?> If you look in the echo part, $dvdlink is supposed to have the id for that particular review, yet when I scroll over on the page, it's blank. Here's the page to look at: http://www.moviemansguide.com/studios/index.php?id=49 Edited October 6, 2007 by TheMovieman Quote
TheMovieman Posted October 6, 2007 Author Posted October 6, 2007 Got it fixed finally. Dumb mistake (all I had to do is remove studio.id). Duh. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.