Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

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.