Php to edite in many record with my sql

SELECT
  ivsdtl.Code,
  prdmas.Name,
  ivsdtl.Qty,
FROM
  ivsdtl,
  prdmas
WHERE
  (ivsdtl.PCode = prdmas.Code)

How can i write pro gram with php so that I can up date   ivsdtl.Qty  at one time with many row  i can write
teeraAsked:
Who is Participating?
 
-Thespian-Connect With a Mentor Commented:
You can build (concatenate) a big SQL statement. and send it to MySQL.
Due to UPDATE syntax can't separate conditions and updates, you need to make something like this:

$sSQL = '';
foreach ($aRecords in $aRecord) {
  if ($sSQL != '') $sSQL .= '; ';
  $sSQL .= "UPDATE ivsdtl SET `Qty`='{$aRecord['NewQty']}' WHERE `PCode`='{$aRecord['Code']}' LIMIT 1"
}

That's all. Than execute it at once.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.