drummer101 Posted November 27, 2007 Share Posted November 27, 2007 [code]<?php $result=mysql_query("SELECT phpbb_user_group.user_id, phpbb_users.username, profile.rlname, profile.name, profile.primary_class, profile.secondary_class FROM phpbb_user_group, phpbb_users, profile WHERE phpbb_user_group.group_id = 6 AND phpbb_users.user_id = phpbb_user_group.user_id ORDER BY profile.name ASC"); echo "<table width=\"451\" height=\"50\" border=\"1\"> <tr> <td class=\"\" align=\"center\"><div class=\"tblheader\">Handle</div></td> <td class=\"\" align=\"center\"><div class=\"tblheader\">Name</div></td> <td class=\"\" align=\"center\"><div class=\"tblheader\">Primary</div></td> <td class=\"\" align=\"center\"><div class=\"tblheader\">Secondary</div></td> </tr>"; while ($i = mysql_fetch_array($result)){ echo "<tr> <td><a href='images/profile.jpg' rel=\"lightbox\" title=\"{$i['username']}\">{$i['username']}</a></td> <td>{$i['rlname']}</td> <td>{$i['primary_class']}</td> <td>{$i['secondary_class']}</td>"; } echo "</table>"; //echo "<p><a href='images/profile.jpg' rel=\"lightbox\" title=\"{$i['username']}\">{$i['username']}</a></p>"; }?> phpbb_username and profile_name are identical fields. The one problem I'm having with this is that when the page loads, theres 10 iterations of everyone's name. What did I miss/mess up to make it do that?[/code] Link to comment https://forums.phpfreaks.com/topic/79054-solved-sql-query-results-in-10x-duplicate-results/ Share on other sites More sharing options...
drummer101 Posted November 27, 2007 Author Share Posted November 27, 2007 The only way I can think of getting around the problem is something like, <?php$result=mysql_query("SELECT phpbb_user_group.user_id, phpbb_users.username FROM phpbb_user_group, phpbb_users WHERE phpbb_user_group.group_id = 6 AND phpbb_users.user_id = phpbb_user_group.user_id ORDER BY `username` ASC"); echo "<table width=\"451\" height=\"50\" border=\"1\"> <tr> <td class=\"\" align=\"center\"><div class=\"tblheader\">Handle</div></td> <td class=\"\" align=\"center\"><div class=\"tblheader\">Name</div></td> <td class=\"\" align=\"center\"><div class=\"tblheader\">Primary</div></td> <td class=\"\" align=\"center\"><div class=\"tblheader\">Secondary</div></td> </tr>"; while ($i = mysql_fetch_array($result)){ $result2=mysql_query("SELECT profile.name, profile.rlname, profile.primary_class, profile.secondary_class FROM profile WHERE profile.name = {$i['username']}"); while ($I = mysql_fetch_array($result2)){ echo "<tr> <td><a href='images/profile.jpg' rel=\"lightbox\" title=\"{$i['username']}\">{$i['username']}</a></td> <td></td> <td> </td> <td> </td> </tr>"; } } echo "</table>";?> The question there though is, is it legal to use the result of an array variable in a SQL query? <?php $result2=mysql_query("SELECT profile.name, profile.rlname, profile.primary_class, profile.secondary_class FROM profile WHERE profile.name = {$i['username']}");?> Link to comment https://forums.phpfreaks.com/topic/79054-solved-sql-query-results-in-10x-duplicate-results/#findComment-400081 Share on other sites More sharing options...
drummer101 Posted November 27, 2007 Author Share Posted November 27, 2007 probably a poorly phrased question. Water under the bridge now though.. I solved the problem. Link to comment https://forums.phpfreaks.com/topic/79054-solved-sql-query-results-in-10x-duplicate-results/#findComment-400149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.