How to match rows in a MySql table with a JSON data of 200 records as input in PHP -


i have database having 10000 users unique phone numbers.and when ever new user registers i'm trying match contacts (nearly 200 500) existing data can find friends (like whats app)

currently m doing using foreach , slow, need in finding reliable solution can reduce time taken multiple queries.

please find code below m using.

$rawdata= file_get_contents('php://input'); $matchedcontacts = array(); $jsonarray = json_decode($rawdata); foreach ( $jsonarray $value)   {    $contactnumber = ($value->num);   $emil= ($value->email);   $name=mysql_query("select * tbl_user  phone='".$contactnumber ."' or email='".$email."'");   while ($nameres= mysql_fetch_array($name))   {    $matchedcontacts [] = array('username'=>$nameres['username'], 'userid'=>$nameres['c_id']);   }  }  echo json_encode ($matchedcontacts ); 

edit: i'm passing local id each record i'm sending. after match, how can map matched record particular local id?

you might want consider importing contacts list (temporary?) table, , use join.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -