Jump to content

Recommended Posts

Thanks Pikachu2000 and Maq.

 

I'm trying to match data from table1 against table2, and then update the 'MatchType' column with the matching count. I know how to match table1 against table2 and get the matching count. But I dont know how to do it to all rows on the fly when the table2 is updated. Could you show me a sample how to update row by rwo on the fly?

 

$query =  "SELECT * FROM table1 WHERE shop = 'B-11'";
//instead of B-11 how can I call each row once to update the "MatchType" column?

 

table1

shop          JAN                  FEB                  MARCH        MatchType

B-11            paid -R            paid -R            paid -F         

B-12            paid -F            paid -F            paid -F         

B-13            paid -R            paid -R            paid -R         

 

 

table2

SHOP          JAN                  FEB                  MARCH

2010            paid -F            paid -R            paid -F         

 

Alright. Let me ask you the question this way... How can I update all the rows in MatchType of table1 using the following code?

 

table1

shop          JAN                  FEB                  MARCH        MatchType

B-11            paid -R            paid -R            paid -F         

B-12            paid -F            paid -F            paid -F         

B-13            paid -R            paid -R            paid -R         

 

 

table2

SHOP          JAN                  FEB                  MARCH

2010            paid -F            paid -R            paid -F 

 

 

$MyArray1 = array();
$MyArray2 = array();
db1
$Variable1 = mysql_real_escape_string($_POST['roundonex'], $conn);
$Variable1 = $_POST['name'];
$queryA1 =  "SELECT * FROM table1 WHERE username = '".$Variable1."'";
$resultA = mysql_query($queryA1);
$scoreA = mysql_fetch_assoc($resultA);
foreach (range('a','h') as $ltr) {
$MyArray1[] = array($scoreA['roundzA' . $ltr]);
}
db2
$$Variable2 = 'roundA';
$query1 =  "SELECT * FROM table2 WHERE roundx = '".$$Variable2."'";
$result = mysql_query($query1);
scoreB = mysql_fetch_assoc($result);
foreach (range('a','h') as $ltr) {
$MyArray2[] = array(scoreB['markwinx' . $ltr]);
}
$count = array();
for($i=0;$i<count($MyArray1);++$i) {
$count[$i] = count(array_intersect($MyArray1[$i],$MyArray2[$i]));
}
$count1 = array_sum($count);[/sup]
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.