Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7750783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:22:46+00:00 2026-06-01T11:22:46+00:00

I am developing an application that updates data in a table based on values

  • 0

I am developing an application that updates data in a table based on values selected from another table. I had searched the net,a nd tried to modify some samples to fit my needs, but still not working.

Below is some of my code:

$sync_2 = "
  select pin,ddt_1
  from purchases
  where (amount_to_repay-amount_repaid)>0
    and status like 'U%'
    and counter=1
";
$sync_2_res = mysqli_query($link, $sync_2);
$row = mysqli_fetch_assoc($sync_2_res);
$data = mysqli_num_rows($sync_2_res);

$i;
for ($i = 0; $i <= $data; $i++) {
  $pin = $row['pin'];
  $ddt = $row['ddt_1'];
  $sql = "
    update deductions
    set amount = '$ddt_1'
    where pin = '$pin';
  $result = mysqli_query($link,$sql);
}

Nothing is getting populated. Do I have to change the type of loop?.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:22:48+00:00Added an answer on June 1, 2026 at 11:22 am

    Try this code, which should do the whole operation in a single query:

    $query = "
      UPDATE `deductions` `d`
      JOIN `purchases` `p` ON `p`.`pin` = `d`.`pin`
      SET `d`.`amount` = `p`.`ddt_1`
      WHERE
        (`p`.`amount_to_repay` - `p`.`amount_repaid`) > 0
        AND `p`.`status` LIKE 'U%'
        AND `p`.`counter` = 1
    ";
    $result = mysqli_query($link, $query);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an application that updates the data in QTableView from apache server
I am developing an application that store some data in a Amazon SimpleDB instance.
I'm developing an application for companies that will automatically post data on their social
I'm currently developing an application that needs to store data in it's on database,
I'm developing application that can be useful only in my country(Ukraine). In Ukraine people
When developing an application that sends out notification email messages, what are the best
I'm developing and application that runs as a Windows service. There are other components
I'm developing an application that manages network interfaces on behalf of the user and
I am developing an application that needs to use regini (because of legacy reasons)
I am actually developing and application that has around 15 modules, all of them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.