Jump to content

Recommended Posts

Posted

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

Posted (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 by TheMovieman

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...