Php to edite  in many record with my sql

Posted on 2007-10-04
Last Modified: 2013-12-13
  (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
Question by:teera
    1 Comment
    LVL 5

    Accepted Solution

    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.

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now