I have two fetch arrays retrieved from the database, and try to compare two values until they have the matching, but it seems bit hard to figure out where I got wrong.
the two database have upto 2 jobrequestnumber so, the number of the matching is supposedly two, but it only counts one(indicated below).
$value1=array();
$value2 =array();
$queryfordispatch = "select jobrequestnumber from dispatch";
$resultfordispatch = mysql_query($queryfordispatch);
$valuefordispatch =mysql_fetch_array($resultfordispatch);
$value1 = $valuefordispatch['jobrequestnumber'];
$queryforjobrequest = "select jobrequestnumber from jobrequest";
$resultforjobrequest = mysql_query($queryfordispatch);
$valueforjobrequest =mysql_fetch_array($resultforjobrequest);
$value2 = $valueforjobrequest['jobrequestnumber'];
$cfd=count($valuefordispatch);
$cfj=count($valueforjobrequest);
//In this for loop, if I try to echo the value of $value1, it only produce the value of "1"
for($i=1; $i<=$cfd; $i++){
for($j=1; $j<=$cfj; $j++){
if ($value1 == $value2 ){
$queryforupdate ="UPDATE jobrequest SET status = 'processed' where jobrequestnumber = $value2 ";
mysql_query($queryforupdate);
}
}
}
So the result that I expect is that
jobnum
1=1? yes --> update
1=2? no --> discard
2=1? no --> discard
2=2? yes --> update