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>"; } Link to comment https://forums.phpfreaks.com/topic/47682-solved-pulling-info-from-2-tables-problem/ 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. Link to comment https://forums.phpfreaks.com/topic/47682-solved-pulling-info-from-2-tables-problem/#findComment-232852 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. Link to comment https://forums.phpfreaks.com/topic/47682-solved-pulling-info-from-2-tables-problem/#findComment-232854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.