Jump to content

[SOLVED] Pulling info from 2 tables problem


SkyRanger

Recommended Posts

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>"; 

}

 

 

 

 

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.