Jump to content

Pull data regardless of the username.


Peter-Colman

Recommended Posts

This is my code. Data is been pulled from db_faq and Db_2 and then match the records against each other using array_intersect(). And as you see the data from db_faq is been pulled based on the $username.

 

My question is how can I ignore the $username and match all rows in db_faq against the data in db_2? Basically I need to get the matching records between the 2 databases regardless of the username.

 

$Array1 = array();
$Array2 = array();
$var1 = '$username';
$query1 =  "SELECT * FROM db_faq WHERE username = '".$var1."'";
$result1 = mysql_query($query1);
$score1 = mysql_fetch_assoc($result1);
foreach (range('25','35') as $ltr) {
$Array1[] = array($score1['roundzA' . $ltr]);
}

$var2 = 'new';
$query =  "SELECT * FROM db_2 WHERE place = schedule";
$result = mysql_query($query);
$score2 = mysql_fetch_assoc($result);
foreach (range('25','35') as $ltr) {
$Array2[] = array($score2['points' . $ltr]);
}
$count = array();
for($i=0;$i<count($Array1);++$i) {
$count[$i] = count(array_intersect($Array1[$i],$Array2[$i]));
}
$countResult = array_sum($count);

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.