SkyRanger Posted April 19, 2007 Share Posted April 19, 2007 Ok, I am trying to pull info from 2 tables. Here is what I am trying to do and here is what I tried but with error: table 1 Members mid muname table 2 posts bid bmid btitle ok, I am trying to pull the info from the 2 tables: mid = bmid Here is what I have so far, but it probably isn't right due to I am getting errors: $resultb2 = mysql_query("SELECT members.*, post.* ". "FROM members, post ". "WHERE members.mid = post.bmid where bid='1'") or die( "Unable to select database"); $wordnum = mysql_num_rows( $resultb2 ); while( $rowb2 = mysql_fetch_array( $resultb2 ) ) { echo $rowb2["btitle"]; echo " - "; echo $rowb2["muname"]; echo "<br>"; } Quote Link to comment Share on other sites More sharing options...
btherl Posted April 19, 2007 Share Posted April 19, 2007 It looks good. But to combine "where" conditions you must use "and". $resultb2 = mysql_query("SELECT members.*, post.* ". "FROM members, post ". "WHERE members.mid = post.bmid AND bid='1'") or die( "Query failed: " . mysql_error()); Try that out.. I also adjusted your error message to match the function. If you still have trouble, try storing your query in a variable and printing it out to see if it looks the way it should look. Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted April 19, 2007 Author Share Posted April 19, 2007 Yeah stupid me - coder error, knew that was suppose to be and, not sure why i put the second where. Thanks for catching that for me. 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.