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

}

 

 

 

 

 

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.