开发者

Mulitple variable containing "for loop" is not working in my code

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.ch开发者_如何学Goangedone )
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.=",";

}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜