RON_ron Posted November 19, 2010 Share Posted November 19, 2010 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 https://forums.phpfreaks.com/topic/219161-match-count-help/ Share on other sites More sharing options...
RON_ron Posted November 19, 2010 Author Share Posted November 19, 2010 Sorry! I if I was not clear... E.g. $winRa1 = $userRa1, $winRa2 = $userRa2,... (if both are matching then it's 2 points.) $winRk1 = $userRk1, $winRk2 = $userRk2,... (if only 1 is matching then it's 1 point.) Hope you experts are clear of that. Link to comment https://forums.phpfreaks.com/topic/219161-match-count-help/#findComment-1136482 Share on other sites More sharing options...
RON_ron Posted November 19, 2010 Author Share Posted November 19, 2010 Am I in the wrong place or is this impossible or are there better ways of doing this? Link to comment https://forums.phpfreaks.com/topic/219161-match-count-help/#findComment-1136498 Share on other sites More sharing options...
RON_ron Posted November 22, 2010 Author Share Posted November 22, 2010 Someone Help..... Link to comment https://forums.phpfreaks.com/topic/219161-match-count-help/#findComment-1137982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.