• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 150
  • Last Modified:

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
0
teera
Asked:
teera
1 Solution
 
-Thespian-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

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now