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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matching

Status
Not open for further replies.

queryguy

Programmer
Oct 10, 2003
23
SG
I am doing a matching script for my site, have problem on the results and sending out part.

------

I have a "users" column on my tablea and "users2" column on my tableb. I need to find out who matches tablea "Users" country criteria from tableb "users2" country criteria.

------

$match="select * from tablea, tableb where tablea.country=tableb.country";
$matchresults = mysql_query($match) ;
while($matched = mysql_fetch_array($matchresults) ){

$results = $matched[users2] matches $matched[users]

//than send to those $matched[users] who have results..

//for example :$matched[users] has results of $matched[users2], $matched[users2], $matched[users2], $matched[users2]
Send this 4 results to $matched[users] in only one email with the 4 results.


}


Hope my explaination is clear, any helps will be really appreciated!
 
sorry I counldn't understand fully what you want... why can't u use SQL statements to do this??

What are you trying to do exactly - find the users whose countries equal each other or find users from both tables that have countries equal to a specific country?

Your current SQL statement:
"select * from tablea, tableb where tablea.country=tableb.country"

should return every user from both tables that have matching(equal) values for their countries. So they are Matched already for you...


Rocco is the BOY!!

SHUT YOUR LIPS...
ROCCOsm.gif
 
no..

bascially I have no problem with the result fetching part what I need is the sending out email part.

If $matched[users] have results, I need to have these 4 results send together to $matched[users] in 1 email instead of 4 emails.. What my problem was I can't compile the 4 results this $matched[users] have and send it to him in one email.

More clearer picture

Matches results from tableb where tabla.country = tableb.country:

apple
orange
pear
grapes
send to $matched[users](tablea) in one email with these 4 results










 
explode()

Rocco is the BOY!!

SHUT YOUR LIPS...
ROCCOsm.gif
 
This is really not that hard.
All you need is accumulate the matched users in a results variable, e.g. an array.
Code:
while($matched = mysql_fetch_array($matchresults) ){
   $results[] = $matched[users];
}

You have to decide what you want to display from the record that you retrieved since you used "*" in the SQL. $results is now a 2-dimenisonal array.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top