facarroll Posted October 24, 2010 Share Posted October 24, 2010 Can anyone see what is wrong here? This is my first serious attempt at this. <?php $query1 = mysql_query(" SELECT topics.url_big, topics.url_small, topics.title, topics.".$egroup.", quiz.passState FROM topics INNER JOIN quiz ON (topics.managerId = quiz.".$managerId.") WHERE topics.".$egroup." = 1 ORDER BY title ASC"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/216691-an-inner-join-problem/ Share on other sites More sharing options...
eran Posted October 24, 2010 Share Posted October 24, 2010 You could have check your mysql_error() and let us know yourself... It seems you are using dynamic variables for columns names in both the column list and ON clause. Those are usually static values - what is the value of $egroup and $managerId? why are those variables? what are the contents of mysql_error()? Quote Link to comment https://forums.phpfreaks.com/topic/216691-an-inner-join-problem/#findComment-1125824 Share on other sites More sharing options...
facarroll Posted October 24, 2010 Author Share Posted October 24, 2010 I reviewed and modified the code. I now get an array, but mostly in duplicate. You can see the duplication in the attached screenshot. This is another problem I guess, but at least the query is working, somewhat. The dynamic variables are session variables that allow the selection of certain columns in the tables. I've posted the code going further, as I think this new problem may emanate from there. <?php $query1 = mysql_query("SELECT topics.url_big, topics.url_small, topics.title, topics.".$egroup.", quiz.passState, quiz.userDate FROM topics INNER JOIN quiz ON (topics.managerId = quiz.managerId) WHERE topics.".$egroup." = 1 ORDER BY title ASC"); ?> <table width="850" style="font-size:16px"> <?php while ($row1 = mysql_fetch_array($query1)) { ?> <tr> <td width="45"></td> <td width="132" style="vertical-align:middle"><?php echo "<a href='../../wood/wood_tool_images/{$row1['url_big']}' target='_blank'><img src='../../wood/wood_tool_images/{$row1['url_small']}' alt='' /><br />\n"; ?></td> <td width="25"></td> <td width="172" style="vertical-align:middle"><?php echo "{$row1['title']} <br />\n"; ?></td> <td width="25"></td> <td width="132" style="vertical-align:middle"><?php echo "<a href='../equipment/{$row1['title']} Safety Quiz/{$row1['title']} Safety Quiz.php'>Take This Quiz</a><br />\n"; ?></td> <td width="25"></td> <td width="112" style="vertical-align:middle"><?php echo "<img src='../../wood/wood_tool_images/{$row2['testcompleted.jpg']}' /><br />\n"; ?></td> <td width="25"></td> <td width="122" style="vertical-align:middle"><?php echo "{$row1['userDate']} <br />\n"; ?></td> <td width="45"></td> </tr> <?php } ?> </table> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/216691-an-inner-join-problem/#findComment-1125826 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.