We help IT Professionals succeed at work.
Get Started

How to update multiple mysql rows and columns using php?

Member_2_6479049
on
449 Views
Last Modified: 2015-02-26
Hi guys,

I have a table that I need to update, this table has 20 columns and 31 rows, it's something like this:

Day   h0400_0415  h0415_0430  h0430_0445  h0445_0500  h0500_0515  h0515_0530  h0530_0545  h0545_0600
01     10                     12                   10                   12                   10                    12                  10                    12                
02     20                     30                   20                   30                   20                    30                  20                    30                  
03     10                     12                   10                   12                   10                    12                  10                    12                  
04     20                     30                   20                   30                   20                    30                  20                    30                  
05     10                     12                   10                   12                   10                    12                  10                    12                  
06     20                     30                   20                   30                   20                    30                  20                    30                  

I know there are a lot of fields, but I need to update all at once.
all the values comes from 620 text boxes, so there are 20 textboxes per day and the name of the text boxes are:

for day 1 =====> h01_0400_0415, h01_0415_0430, h01_0430_0500 ......... until h01_0845_0900
for day 2 =====> h02_0400_0415, h02_0415_0430, h02_0430_0500 ......... until h02_0845_0900
for day 3 =====> h03_0400_0415, h03_0415_0430, h03_0430_0500 ......... until h03_0845_0900


And this is my query I'm trying to build:

      $mysqli1 = new mysqli($DBhost, $DBuser, $DBpass, $DBname);
      if ($mysqli1->connect_errno) {
            printf("No fue posible conectarse a la base de datos: %s\n", $conn->connect_error);
            exit();
      }else{
            $result1 = "UPDATE control_citas SET h0400_0415 = '$_POST['01_h0400_0415']', h0415_0430 = '$_POST['01_h0415_0430']'  WHERE ano = '2015' && mes = '$mes'";
            if (!$result1) {
                  echo "NO SE PUDO ACTUALIZAR LA BASE DE DATOS";
                  exit();
            }else{

Please guys any advaice??

Thank you.
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2020
Most Valuable Expert 2018
Commented:
This problem has been solved!
Unlock 3 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE