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
https://forums.phpfreaks.com/topic/220936-pull-data-regardless-of-the-username/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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