Jump to content

MATCH & COUNT : Help


RON_ron

Recommended Posts

How to write this in a shorter way?

 

I've got a set of results and I need to check them against another database results. If they both are similar then I want to make it as "1" (points). The questions and the answers are in the same order (Question1, Question2, Question3 = Answer1, Answer2, Answer3). sa I guess the maching could be done using a set of arrays.

 

E.g.

get records from db1 get records from db2

get records from dbY get records from dbX

COUNT the matching data from db1 against dbY = echo TOTAL_SCORE1

COUNT the matching data from db2 against dbX = echo TOTAL_SCORE2

 

I've managed to get the data from the databases in order. But i need to get the COUNT of the MATCHING records.

 

 

php

\\Assume this is db1
$SomeVar = $_POST['sitting2'];
$queryU =  "SELECT * FROM adxone WHERE username = '".$SomeVar."'";
$resultU = mysql_query($queryU);
$scoreU = mysql_fetch_assoc($resultU);
$userRa1 = $scoreU['roundzAa'];
$userRa2 = $scoreU['roundzAb'];
$userRa3 = $scoreU['roundzAc'];
$userRa4 = $scoreU['roundzAd'];
$userRa5 = $scoreU['roundzAe'];
$userRa6 = $scoreU['roundzAf'];
$userRa7 = $scoreU['roundzAg'];
$userRa8 = $scoreU['roundzAh'];

\\ Assume this is dbY
$WinVar = 'examinationA';
$query =  "SELECT * FROM markacs WHERE roundx = '".$WinVar."'";
$result = mysql_query($query);
$scoreM = mysql_fetch_assoc($result);
$winRa1 = $scoreM['markwinxa'];  
$winRa2 = $scoreM['markwinxb']; 
$winRa3 = $scoreM['markwinxc']; 
$winRa4 = $scoreM['markwinxd']; 
$winRa5 = $scoreM['markwinxe']; 
$winRa6 = $scoreM['markwinxf']; 
$winRa7 = $scoreM['markwinxg']; 
$winRa8 = $scoreM['markwinxh']; 

/*need to match if 
$winRa1 = $userRa1, $winRa2 = $userRa2, etc..

then get the COUNT of the matching results*/

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.