Jump to content

[SOLVED] Table Join Issue... should only echo one result, instead echoing LIMIT of 25


suttercain

Recommended Posts

Hi everyone,

 

I am using the following code in a table join:

 $query = mysql_query("SELECT user_comics.comic_id, comics.cover_art, comics.comic_id FROM user_comics, comics WHERE user_comics.user_id = '".mysql_real_escape_string($_GET['title'])."'    
  $limit") or die(mysql_error());
}

 

The $limi variable is set to 25 and the $_GET['title'] has only one result in the table, yet I get 25 results. On top of that it echos the first 25 results from the comics table and not even the one that it should call.

 

Both tables user_comics and comics share the comic_id column. I am attempting to pull information from the comics table where the user_id matches the same comic_id.

 

Am I going about this all wrong?

 

Thanks.

SELECT 
   user_comics.comic_id, comics.cover_art, comics.comic_id 
FROM user_comics
LEFT JOIN comics 
ON user_comics.comic_id = comics.comic_id
WHERE user_comics.user_id = '{$_GET['title']}'    
LIMIT $limit

 

I left out the mysql_real_escape_string just to make it easier for me. I also added the LIMIT before the $limit var. You said it only held "25", so you could have possibly forgot the LIMIT part.

 

If that doesn't work, echo it out and see if the query is printing out okay. Also post what it prints out for us.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.