Table Joins Code Problem

liunx

Guest
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.<br /><br />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.<br /><br />Here's how I have my tables set up, with the column names pertaining to this code:<br /><br />dvd_reviews (id, title, year)<br />studio (id, name)<br />moviestudio (movieid, studioid)<br /><br />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.<br /><br />Here's what I've been trying:<br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><br /><?php<br /><br />$movietitles = @mysql_query("SELECT title, year, dvd_reviews.id, movieid, studioid FROM dvd_reviews, moviestudio WHERE studioid='$id' AND movieid=dvd_reviews.id");<br />if (!$movietitles) {<br /> exit('<p>Error retrieving information from database.<br />'.<br /> 'Error: ' . mysql_error() . '</p>');<br />}<br /><br />while ($title-dvd = mysql_fetch_array($movietitles)) {<br />$dvdtitle = $title-dvd['title'];<br />$year = $title-dvd['year'];<br />echo "<tr><td>$dvdtitle ($year)</td></tr>"<br /><br />}<br />?><br /></div><br /><br />I've tried other variations on that but get a parse error everytime:<br />"Parse error: syntax error, unexpected '=' in /home2/*removed*/public_html/studios/index.php on line 114"<br /><br />I know I'm missing something, but I can't figure out what.<br /><br />Thanks in advance <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br />Brian<!--content-->
And I know I missed a " ; " at the end of the echo statement. I've put it in and still get the parse error.<!--content-->
Edit: Nevermind. Somehow fixed it... Dunno what happened but I redid the code and now it works.<br /><br />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:<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?php<br /><br />$movielist = @mysql_query("SELECT title, year, movieid, studioid, dvd_reviews.id, studio.id FROM dvd_reviews, studio, <br /><br />moviestudio WHERE movieid=dvd_reviews.id AND studioid='$id' AND studio.id='$id'");<br />if (!$movielist) {<br /> exit('<p>Error retrieving information from database.<br />'.<br /> 'Error: ' . mysql_error() . '</p>');<br />}<br /><br />while ($listing = mysql_fetch_array($movielist)) {<br />$title = $listing['title'];<br />$year = $listing['year'];<br />$dvdlink = $listing['dvd_reviews.id'];<br />echo "<tr><td><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/'http://www.moviemansguide.com/reviews/DVD/read.php? id=$dvdlink'>$title</a></td><td>$year</td></tr>";<br />}<br /><br />?></div><br /><br />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.<br /><br />Here's the page to look at:<br /><a href="http://www.moviemansguide.com/studios/index.php?id=49" target="_blank">http://www.moviemansguide.com/studios/index.php?id=49</a><!--content-->
Got it fixed finally. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> <br /><br />Dumb mistake (all I had to do is remove studio.id). Duh. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid=":p" border="0" alt="tongue.gif" /><!--content-->
I纾
 
Top