astralaaron Posted February 2, 2008 Report Share Posted February 2, 2008 $sql1 = mysql_query("SELECT * FROM `forum_topic` WHERE id='$id'");while ($row = mysql_fetch_array($sql1)) {$usr = $row['user_id'];mysql_select_db("sb_members");$sqlu = mysql_query("SELECT * FROM `roster` WHERE uni_id='$usr'");while ($user = mysql_fetch_array($sqlu)){one of the rows in the first loop has the user_id so i can pull their info from the members database..without the 2nd while loop it displas the $row[''] info but when i add the 2nd one it doesnt display either. Link to comment Share on other sites More sharing options...
killboy Posted February 2, 2008 Report Share Posted February 2, 2008 No, it's not... something that's "against the rules" is some syntax or parse error; and that's when the compiler tells you that what you're trying to do is not possible. Everything the compiler let you do is not "against the rules".Edit: you can have as many loops inside another loops as you want Link to comment Share on other sites More sharing options...
jhecht Posted February 2, 2008 Report Share Posted February 2, 2008 No its not against the rules, but why are you pulling SQL from another database? You could just add all the tables you've got in your current db to your other and you wouldn't have to call the mysql_select_db function again. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 4, 2008 Report Share Posted February 4, 2008 If you're working with more then one database then use more then one connection. If you're only working with one database you don't need to use connections. But you do. $con1 = mysql_connect(...);mysql_select_db('db1', $con1);$con2 = mysql_connect(...);mysql_select_db('db2', $con2);$sql1 = mysql_query("SELECT * FROM `forum_topic` WHERE id='$id'", $con1);while ($row = mysql_fetch_array($sql1)) { $usr = $row['user_id']; $sqlu = mysql_query("SELECT * FROM `roster` WHERE uni_id='$usr'", $con2); while ($user = mysql_fetch_array($sqlu)){ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now