mdub2112 Posted December 12, 2006 Share Posted December 12, 2006 The end result I'm looking for is:Client's Name Record1 Record2 Record3Client's Name Record1 Record2 Record3The query I'm using is[code=php:0] $uploads_sql = "select * from user_permissions, uploads, clients where user_permissions.username = '{$_SESSION['auth_user']}' and uploads.client = clients.code and clients.code = user_permissions.company"; $uploads_result = $handle->query($uploads_sql);[/code][b]The while loop I'm using is[/b][code=php:0] while ($uploads = $uploads_result->fetch_assoc()) {echo '<tr><td>';echo $uploads['client'];echo '</td></tr>';echo '<tr><td>';echo $uploads['comments'];echo '</td></tr>';echo '<tr><td>';echo 'Download: '."<a href=download.php?id={$uploads['id']}>{$uploads['title']}<br /></a>";echo '[<a href="delete_record.php?file='.$uploads['id'].'">Delete Record</a>] ';echo '</td></tr>'; }[/code]With that query and code I get:Client's NameRecord1Client's NameRecord2Client's NameRecord3If I change the query to include GROUP BY client, it only shows one record. How can I go about getting the end result I'm looking for?Sort of a noob here so...Hopefully I've given the info needed to see what I'm doing. Quote Link to comment https://forums.phpfreaks.com/topic/30368-group-byorder-by/ Share on other sites More sharing options...
The Little Guy Posted December 12, 2006 Share Posted December 12, 2006 have you tried DISTINCT$uploads_sql = "select DISTINCT clients, * from user_permissions, uploads, clients where user_permissions.username = '{$_SESSION['auth_user']}' and uploads.client = clients.code and clients.code = user_permissions.company"; Quote Link to comment https://forums.phpfreaks.com/topic/30368-group-byorder-by/#findComment-139841 Share on other sites More sharing options...
mdub2112 Posted December 12, 2006 Author Share Posted December 12, 2006 Looks like DISTINCT is going to do exactly what I want.THANKSOnly problem I have now LOL is trying to figure out how to resolve the [color=red]Trying to get property of non-object in /var/www/html/blablabla on line 34[/color] message I'm getting(line 34 = [color=purple]echo $user['fullname'].' You have access to ' . $uploads_result->num_rows . ' records.'[/color]) Quote Link to comment https://forums.phpfreaks.com/topic/30368-group-byorder-by/#findComment-139928 Share on other sites More sharing options...
The Little Guy Posted December 13, 2006 Share Posted December 13, 2006 Something like this maybe?[code] $row = mysql_query($uploads_sql); $num_rows = mysql_num_rows($uploads_sql);echo $user['fullname'].' You have access to ' . $num_rows . ' records.';[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30368-group-byorder-by/#findComment-140565 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.