I have to execute mulitple UPDATE queries for different parameters using a for loop. Now the problem is that whenever I do it, only my last query gets executed, all the previous queries seem to be skipped.
foreach ($flagSet as $controlDoc => $controlFlag)
{
for ($t = 0; $t < count($controlFlag); $t++)
{
$userLevel = "controller";
$docFlag = 1;
$postfix = "created";
$createDoc->updateFlags($controlFlag[$t], $docFlag, $controlDoc, $postfix, $userLevel);
$docFlag = 2;
$postfix = "midlevel";
$createDoc->updateFlags($controlFlag[$t], $docFlag, $controlDoc, $postfix, $userLevel);
}
}
The called function
$query = "UPDATE tbl_docuserstatus SET";
if($flag != "")
{
$query .= " docseeflag_" . $postfix . " = '" . $flag . "'";
}
$query .= " WHERE doc_id = '" . $doc_id . "' AND user_id = '" . $user_id . "'";
if($userLevel == "midlevel")
{
$query .= " AND doc_midlvluser = '1'";
}
elseif ($userLevel == "finalLevel")
{
$query .= " AND doc_finallvluser = '1'";
}
elseif ($userLevel == "creator")
{
$query .= " AND doc_creator = '1'";
}
elseif ($userLevel == "controller")
{
$query .= " AND doc_controller = '1'";
}
elseif ($docarchive == 1)
{
$query .= " AND doc_controller = '1'";
}
So could some one tell me, how to set the delay between update queries in Mysql so that every query get executed succesfully?
There is no need to put a delay in, there should be some other error. (like @Charles said in the comment).
What you should do, and all I can advice I think with current code, is echo all the queries you are performing, and verify that they are correct. Do this not only by looking at them, but execute them in a mysql client (commandline, phpmyadmin, etc).
If they do execute correctly, check if your PHP code runs all the queries at the rigth moment: does it actually execute the query-strings you are building?