Link to home
Start Free TrialLog in
Avatar of Member_2_6479049
Member_2_6479049

asked on

How to update multiple mysql rows and columns using php?

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.
SOLUTION
Avatar of Daniel Wilson
Daniel Wilson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_6479049
Member_2_6479049

ASKER

Thank you guys,

Actually, this app is to be used for a short period of time, the user page is already done and this one is to administer how many appointments we need per day, but to tell the truth, is much more easy to change values directly on the database because during this period is it possible that the values remain the same until the end, and there is another job that I had to stop, As soon as I have time I will learn some more about.

Thank you again :)