suttercain Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72131-solved-table-join-issue-should-only-echo-one-result-instead-echoing-limit-of-25/ Share on other sites More sharing options...
pocobueno1388 Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72131-solved-table-join-issue-should-only-echo-one-result-instead-echoing-limit-of-25/#findComment-363622 Share on other sites More sharing options...
suttercain Posted October 6, 2007 Author Share Posted October 6, 2007 That did it. I need to re-read my chapter on JOINS and LEFT JOINS. Thanks again for the help. SC Quote Link to comment https://forums.phpfreaks.com/topic/72131-solved-table-join-issue-should-only-echo-one-result-instead-echoing-limit-of-25/#findComment-363626 Share on other sites More sharing options...
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.