Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search one table, then display another table where keys match ? 1

Status
Not open for further replies.

leegold

Technical User
Mar 19, 2002
39
US
The only way I can think of to explain what I want to do
is to give you my working newbie code that I'm learning
PHP/MYSQL with, and at a certain point in the code state
exactly as I can what I want to try to do. It's probably
quite simple but I can't get it- Thanks:

...
<pre>
<?php
$dblink = mysql_connect ( 'localhost', "guest", "password" );
mysql_select_db( "balloon", $dblink );
// Doing a FULLTEXT search
// Re the SELECT: I indexed both fields together, so seemed like
// I should put them both in the MATCH...OK, it works.
$query="SELECT * FROM balloon_txt WHERE MATCH(access_no, recs_txt) AGAINST ('robin')";
$result = MySQL_query($query);

/////////////////////////////////
OK, right here - next below I'm gonna display/loop $result from table balloon_txt. But, what I really want to do is take the "result set" access_no fields from the search above and (access_no is a Key in all my tables) and use it to generate results (ie. matching records) from another table called balloon_rec and dispaly/loop the results from balloon_rec. So I'm searching balloon_txt, getting results, but I want to display matching records from another table - balloom_rec. Is there a way to do a join or something in the SELECT above? Or do I process $result? Seems a join in the SELECT above or some SQL above is cleaner - but not sure how(?) Thanks, Lee G.
///////////////////////////////

while ( $row = mysql_fetch_row( $result ) ) {
for ( $i=0; $i<mysql_num_fields( $result ); $i++ )
{echo $row[$i] . " ;}
echo"\n\n\n";
}
// Close the db connection
mysql_close ( $dblink );
?>
</pre>
...
 
select a.* from
balloon_rec a inner join balloon_txt b on
a.access_no = b.access_no
where
MATCH(b.access_no, b.recs_txt) AGAINST ('robin')";

Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top