tags:

views:

26

answers:

1

Below is the code I am working with and the last for loop i am iterating is not working... I think i am doing something wrong using multiple variable in a for loop,also I m aware of the fact that it can be done.

$updaterbk = "SELECT j1. *
FROM jos_audittrail j1
LEFT OUTER JOIN jos_audittrail j2 ON ( j1.trackid != j2.trackid
AND j1.field != j2.field
AND j1.changedone < j2.changedone )
WHERE j1.operation = 'UPDATE'
AND j2.id IS NULL
";

$selectupdrbk = mysql_query($updaterbk);
while($row1 = mysql_fetch_array($selectupdrbk))
{   
    $updrbk[] = $row1;
}

foreach($updrbk as $upfield)
{
if(!in_array($upfield['field'],$exist))
{
    $exist[] = $upfield['field'];
    $existval[] = $upfield['oldvalue'];

    //echo $updqueryrbk = "UPDATE `".$upfield['table_name']."` SET ";
}
}
print_r($existval);

for($i=0;$j=0;$i<count($exist);$j<count($existval);$i++;$j++)
{ 
$updqueryrbk.= $exist[$i]['field']."=".$existval[$j]['oldvalue'].",";
$updqueryrbk.="=";
$updqueryrbk.= $existval[$j]['oldvalue'];

$updqueryrbk.=",";

}
+2  A: 

You have too many ;. Instead of

for($i=0;$j=0;$i<count($exist);$j<count($existval);$i++;$j++)

you should write

for ($i=0, $j=0; $i<count($exist) && $j<count($existval); $i++, $j++)

for takes exactly three expressions as arguments in the form of

for (initialization; condition; step)

foo, bar is a single expression, foo; bar is not - the semicolon is used to separate statements, not expressions.

Tgr
Thanks It worked.. i rectified It with ur help...
OM The Eternity