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 9199521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:33:06+00:00 2026-06-17T22:33:06+00:00

i have written a very simple script for updating multiple values in different columns.

  • 0

i have written a very simple script for updating multiple values in different columns.
My issue is that when i try to update values in columns it work fine, but in case of check box the values are inserting incorrectly.

for ex . if i have 7 rows to update and in selection option i select 1 , 2 , 3 check box and i don’t select 4 5 and again select 6 7 then on updating it take select for 1 , 2 , 3 ,4 ,5 and leaving 6 7 unselected

i am pasting my codes here

form

     <?php include("db.php");

          $id = $_GET['id'];
   $tDate2=$_GET['tDate2'];
 ?> <form method="POST" style="width:50%" action="updatemonthly.php"  >
  <table id="rounded-corner">


    <?php
    $conn=mysql_connect("localhost","root","root") or die(mysql_error());
    mysql_select_db("monthly_pmc_admin") or die(mysql_error()); 
     $result1 = mysql_query("SELECT * from project_details where id ='$id' ;");
     $row = mysql_fetch_assoc($result1);
     $pno=$row['Project_No'];
    $result = mysql_query("SELECT * from capex_phasing_data where Project_Number ='$pno' order by id ;");
     ?>
    <thead>
      <tr>
        <th colspan="6" scope="col" class="rounded-company">Edit/ Delete Capex Graph Values</th>
        <th scope="col" class="rounded-q1"> <?php echo $tProjNo ?></th>
        <th scope="col" class="rounded-q4"></th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <td colspan="7" class="rounded-foot-left" align="center"><input type="submit" name="submit" value="DELETE" id='myButton1' />
          <input type="submit" name="submit" value="UPDATE" id='myButton1' />
         <?php 
         echo 
          '<a href="../capex.php?id=' . $id . '&tDate2='.$tDate2.'"> Add New Capex Value</a>';
          ?></td>
        <td class="rounded-foot-right"></td>
      </tr>
       <tr>
            <td colspan="4" class="rounded-foot-left" align="center"> <?php 
            echo('<A hREF="http://10.26.162.84/graph1/default.aspx?id='.$pno .'&tDate2='. $tDate2. '" target="_blank"> View Graph </A>');?></td>
            <td class="rounded-foot-right"></td>
          </tr>
    </tfoot>
    <tr>
      <th align='center'> Select to <br/>
        Delete Record </th>
      <th >Month</th>
      <th>Planned Phasing </th>
      <th>Actual Phasing </th>
       <th>Select To Display Value in Graph</th>

    </tr>
    <?
    for($i=1;$i<=mysql_num_rows($result);$i++) {
    $row = mysql_fetch_assoc($result);
    ?>
    <tr>
      <td align='left' ><input  type="checkbox" name="chk[]"  value="<?=$row['id']?>" align='center' />
      </td>
      <td align='left'><input type="text" name="month[]" size="10" id="jj" value="<?php echo $row['Month'];?>"  />
      </td>
      <td align='center' ><input name="planman1[]"  size="50" type="text" id="rr" value="<?php echo $row['Planned_Phasing'];?>"  />
      </td>
      <td align='center' ><input name="planman2[]" type="text" size="8" id="r1r" value="<?php echo $row['Actual_Phasing'];?>"  />
      </td>

      <td align='center' ><input name="planman5[]" type="checkbox" id="r4r"  <? if($row['Select_project']==1) {echo 'checked';} ?>  />
      </td>

        <input  type="hidden" name="rowid[]"  value="<?=$row['id']?>" align='center' />
        <input type="hidden" name="ProjNo" value="<?php echo $id; ?>">
          <input type="hidden" name="tDate2" value="<?php echo $tDate2; ?>">
        <!--<input type="hidden" name="ProjNo" value="<?php echo $tProjNo; ?>">-->
      </td>
    </tr>
    <?php
     }
     ?>

update query

<?php
session_start();
require_once('dbclass/database.php');
$myClass=new database();
//echo $_POST['name'];
  $array=$_POST['rowid'];
  $month=$_POST['month'];
  $planman1=$_POST['planman1'];
  $planman2=$_POST['planman2'];
  $planman3=$_POST['planman3'];
  $planman4=$_POST['planman4'];
  $planman5=$_POST['planman5'];
  $actuanman=$_POST['actuanman'];
  $length=count($_POST['rowid']);
  $chk=$_POST['chk'];
  $projno=$_POST['ProjNo'];
  $tDate2=$_POST['tDate2'];

  if($_POST['submit']=='UPDATE'){


for($a=0;$a<$length;$a++){
    $rid=$array[$a];
   $array[$a];
   $month[$a];
   $planman1[$a];
   $planman2[$a];
   $planman3[$a];
   $planman4[$a];
   $planman5[$a];
   $ac= $actuanman[$a];

 if($ac=='on'){$ch=1;} else {$ch=0;}


 if($planman5[$a]=='on'){$planman5[$a]='1';} else {$planman5[$a]='0';}

 $sql="UPDATE  capex_phasing_data set   Month='".$month[$a]."',   Planned_Phasing='".$planman1[$a]."' , Actual_Phasing='".$planman2[$a]."',    Select_project='".$planman5[$a]."' where id='".$rid."'";

mysql_query($sql) or die(); 

header("location:#");
}

}
  • 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-17T22:33:07+00:00Added an answer on June 17, 2026 at 10:33 pm

    finally after understanding i have found the solution for my own problem thank you lex and sujit for your precious time and help

    i have change in my form for the chck box as

    <td align='center' ><input name="planman2[]" type="text" size="8" id="r1r" value="<?php echo $row['Actual_Phasing'];?>"  />
      </td>
    
      <td align='center' ><input name="**planman5<?=$i?>**" type="checkbox" id="r4r"  <? if($row['Select_project']==1) {echo 'checked';} ?>  />
      </td>
    

    and in the update script

    for($a=0;$a<$length;$a++){
    $rid=$array[$a];
    $array[$a];
    $month[$a];
    $planman1[$a];
    $planman2[$a];
    $planman3[$a];
    $planman4[$a];
    **$p=$a+1;
    $p5= $_POST['planman5'.$p];
    if($p5=='on'){$ch1=1;} else {$ch1=0;}**
    

    now its working perfectly fine…

    thank you for your help and the suggestion

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a very simple page counter and a logging script that increments
I am learning jQuery and I have written a very simple script that works
I have written a very simple script with jQuery, but it does not work
I have written a very very very simple!! script in php. header redirection not
I have written a very simple CTE expression that retrieves a list of all
I have written a very simple application to update my twitter status on a
I have written a very simple WCF service, that worked fine (code below), then
I have a very simple DLL written in unmanaged C++ that I access from
I have written a simple jQuery script that changes the hash tag of a
I've written a very simple 'deploy' script running as my post-update hook inside my

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.