MasterACE14 Posted March 8, 2008 Share Posted March 8, 2008 hey guys, I'm having trouble with a query, it was working fine when I was selecting columns from just the 1 table, but when I try and select from 2 tables at the same time its showing the first result in the table over and over again, instead of all the results. here's my code(relevant parts only): <?php $query = "SELECT * FROM `cf_users`,`cf_users2` ORDER BY `cf_users`.`rank` asc LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); while ($a_row = mysql_fetch_array( $result ) ) { $all_id = stripslashes($a_row['id']); $all_name = stripslashes($a_row['username']); $all_rank = stripslashes($a_row['rank']); $all_title = stripslashes($a_row['title']); // this is the only column from the second table (cf_users2) $all_race = stripslashes($a_row['race']); $all_money = stripslashes($a_row['money']); $all_covertaction = stripslashes($a_row['covertaction']); any help is greatly appreciated! Regards ACE Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 8, 2008 Share Posted March 8, 2008 i think you need a WHERE clause tying the two tables together. otherwise, you'll get every possible version of table 1 and table 2 together. something more like: $query = "SELECT * FROM `cf_users`,`cf_users2` WHERE cf_users.id = cf_users2.other_id ORDER BY `cf_users`.`rank` asc LIMIT $limitvalue, $limit"; Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted March 8, 2008 Author Share Posted March 8, 2008 thats done it! Thankyou BlueSkyIS Regards ACE Quote Link to comment 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.