Jump to content

An INNER JOIN problem.


facarroll

Recommended Posts

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");
?>

Link to comment
Share on other sites

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()?

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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.