Skip to main content
adicionou 6 caracteres ao conteúdo
Fonte Link

Segue um exemplo, espero que ajude!
<?php

 <?php 
    $linha = [];

    $linha[1] = array("id" => 1, 'field' => "valor", 'field2' => "valor2");
    $linha[2] = array("id" => 2, 'field' => "valor", 'field2' => "valor2");
    $linha[3] = array("id" => 3, 'field' => "valor", 'field2' => "valor2");
    $linha[4] = array("id" => 4, 'field' => "valor", 'field2' => "valor2");
    $linha[5] = array("id" => 5, 'field' => "valor", 'field2' => "valor2");

    echo '<form action="" method="post">';
    echo '<ul>';
    for ($i=1; $i <= count($linha); $i++) { 
echo '<ul>
    <li><input    echo '<li><input type="checkbox" name="teste[ex'.$i.'][id]"      value="'.$linha[$i]["id"].'"></li>
        <li><input type="text"  name="teste[ex'.$i.'][field]" value="'.$linha[$i]["field"].'"></li>
        <li><input type="text"  name="teste[ex'.$i.'][field2]" value="'.$linha[$i]["field2"].'"></li>
</ul>';li>';
    }
    echo '<br><br>'</ul><br><br>
       <input type="submit" value="OK">
    </form>';

    if (isset($POST['teste']$_POST['teste'])) {
       $data = $_POST['teste']; 
       if ($data != null) {
            foreach ($data as $key => $value) {
                if (isset($value['id']) && !empty($value['id'])) {
                    $query = "UPDATE table SET field =".$value['field'].",field2 =".$value['field2']." WHERE id= ".$value['id'];
                    $query = rtrim($query, ", ");
                    echo "<pre>$query";
                }
            }
        }
    }
    ?>

Segue um exemplo, espero que ajude!
<?php

$linha = [];

$linha[1] = array("id" => 1, 'field' => "valor", 'field2' => "valor2");
$linha[2] = array("id" => 2, 'field' => "valor", 'field2' => "valor2");
$linha[3] = array("id" => 3, 'field' => "valor", 'field2' => "valor2");
$linha[4] = array("id" => 4, 'field' => "valor", 'field2' => "valor2");
$linha[5] = array("id" => 5, 'field' => "valor", 'field2' => "valor2");

echo '<form action="" method="post">';

for ($i=1; $i <= count($linha); $i++) { 
echo '<ul>
    <li><input type="checkbox" name="teste[ex'.$i.'][id]"      value="'.$linha[$i]["id"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field]" value="'.$linha[$i]["field"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field2]" value="'.$linha[$i]["field2"].'"></li>
</ul>';

echo '<br><br>
   <input type="submit" value="OK">
</form>';

if (isset($POST['teste'])) {
   $data = $_POST['teste']; 
   if ($data) {
      foreach ($data as $key => $value) {
         if (isset($value['id']) && !empty($value['id'])) {
            $query = "UPDATE table SET field =".$value['field'].",field2 =".$value['field2']." WHERE id= ".$value['id'];
            $query = rtrim($query, ", ");
            echo "<pre>$query";
        }
     }
   }
}
 <?php 
    $linha = [];

    $linha[1] = array("id" => 1, 'field' => "valor", 'field2' => "valor2");
    $linha[2] = array("id" => 2, 'field' => "valor", 'field2' => "valor2");
    $linha[3] = array("id" => 3, 'field' => "valor", 'field2' => "valor2");
    $linha[4] = array("id" => 4, 'field' => "valor", 'field2' => "valor2");
    $linha[5] = array("id" => 5, 'field' => "valor", 'field2' => "valor2");

    echo '<form action="" method="post">';
    echo '<ul>';
    for ($i=1; $i <= count($linha); $i++) { 

        echo '<li><input type="checkbox" name="teste[ex'.$i.'][id]"      value="'.$linha[$i]["id"].'"></li>
        <li><input type="text"  name="teste[ex'.$i.'][field]" value="'.$linha[$i]["field"].'"></li>
        <li><input type="text"  name="teste[ex'.$i.'][field2]" value="'.$linha[$i]["field2"].'"></li>';
    }
    echo '</ul><br><br>
       <input type="submit" value="OK">
    </form>';

    if (isset($_POST['teste'])) {
       $data = $_POST['teste']; 
       if ($data != null) {
            foreach ($data as $key => $value) {
                if (isset($value['id']) && !empty($value['id'])) {
                    $query = "UPDATE table SET field =".$value['field'].",field2 =".$value['field2']." WHERE id= ".$value['id'];
                    $query = rtrim($query, ", ");
                    echo "<pre>$query";
                }
            }
        }
    }
    ?>
adicionou 11 caracteres ao conteúdo
Fonte Link

Segue um exemplo, espero que ajude!
<?php

$linha = [];

$linha[1] = array("id" => 1, 'field' => "valor", 'field2' => "valor2");
$linha[2] = array("id" => 2, 'field' => "valor", 'field2' => "valor2");
$linha[3] = array("id" => 3, 'field' => "valor", 'field2' => "valor2");
$linha[4] = array("id" => 4, 'field' => "valor", 'field2' => "valor2");
$linha[5] = array("id" => 5, 'field' => "valor", 'field2' => "valor2");

echo '<form action="" method="post">';

for ($i=1; $i <= count($linha); $i++) { 
echo '<ul>
    <li><input type="checkbox" name="teste[ex'.$i.'][id]"      value="'.$linha[$i]["id"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field]" value="'.$linha[$i]["field"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field2]" value="'.$linha[$i]["field2"].'"></li>
</ul>';

echo '<br><br>
   <input type="submit" value="OK">
</form>';

if (isset($POST['teste'])) {
   $data = $_POST['teste']; 
   if ($data) {
      foreach ($data as $key => $value) {
         if (isset($value['id']) && !empty($value['id'])) {
            $query = "UPDATE table SET field =".$value['field'].",field2 =".$value['field2']." WHERE id= ".$value['id'];
            $query = rtrim($query, ", ");
            echo "<pre>$query";
        }
     }
   }
}

}

Segue um exemplo, espero que ajude!
<?php

$linha = [];

$linha[1] = array("id" => 1, 'field' => "valor", 'field2' => "valor2");
$linha[2] = array("id" => 2, 'field' => "valor", 'field2' => "valor2");
$linha[3] = array("id" => 3, 'field' => "valor", 'field2' => "valor2");
$linha[4] = array("id" => 4, 'field' => "valor", 'field2' => "valor2");
$linha[5] = array("id" => 5, 'field' => "valor", 'field2' => "valor2");

echo '<form action="" method="post">';

for ($i=1; $i <= count($linha); $i++) { 
echo '<ul>
    <li><input type="checkbox" name="teste[ex'.$i.'][id]"      value="'.$linha[$i]["id"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field]" value="'.$linha[$i]["field"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field2]" value="'.$linha[$i]["field2"].'"></li>
</ul>';

echo '<br><br>
   <input type="submit" value="OK">
</form>';

if (isset($POST['teste'])) {
   $data = $_POST['teste']; 
   if ($data) {
    foreach ($data as $key => $value) {
        if (isset($value['id']) && !empty($value['id'])) {
            $query = "UPDATE table SET field =".$value['field'].",field2 =".$value['field2']." WHERE id= ".$value['id'];
            $query = rtrim($query, ", ");
            echo "<pre>$query";
        }
    }
}

}

Segue um exemplo, espero que ajude!
<?php

$linha = [];

$linha[1] = array("id" => 1, 'field' => "valor", 'field2' => "valor2");
$linha[2] = array("id" => 2, 'field' => "valor", 'field2' => "valor2");
$linha[3] = array("id" => 3, 'field' => "valor", 'field2' => "valor2");
$linha[4] = array("id" => 4, 'field' => "valor", 'field2' => "valor2");
$linha[5] = array("id" => 5, 'field' => "valor", 'field2' => "valor2");

echo '<form action="" method="post">';

for ($i=1; $i <= count($linha); $i++) { 
echo '<ul>
    <li><input type="checkbox" name="teste[ex'.$i.'][id]"      value="'.$linha[$i]["id"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field]" value="'.$linha[$i]["field"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field2]" value="'.$linha[$i]["field2"].'"></li>
</ul>';

echo '<br><br>
   <input type="submit" value="OK">
</form>';

if (isset($POST['teste'])) {
   $data = $_POST['teste']; 
   if ($data) {
      foreach ($data as $key => $value) {
         if (isset($value['id']) && !empty($value['id'])) {
            $query = "UPDATE table SET field =".$value['field'].",field2 =".$value['field2']." WHERE id= ".$value['id'];
            $query = rtrim($query, ", ");
            echo "<pre>$query";
        }
     }
   }
}
Fonte Link

Segue um exemplo, espero que ajude!
<?php

$linha = [];

$linha[1] = array("id" => 1, 'field' => "valor", 'field2' => "valor2");
$linha[2] = array("id" => 2, 'field' => "valor", 'field2' => "valor2");
$linha[3] = array("id" => 3, 'field' => "valor", 'field2' => "valor2");
$linha[4] = array("id" => 4, 'field' => "valor", 'field2' => "valor2");
$linha[5] = array("id" => 5, 'field' => "valor", 'field2' => "valor2");

echo '<form action="" method="post">';

for ($i=1; $i <= count($linha); $i++) { 
echo '<ul>
    <li><input type="checkbox" name="teste[ex'.$i.'][id]"      value="'.$linha[$i]["id"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field]" value="'.$linha[$i]["field"].'"></li>
    <li><input type="text"  name="teste[ex'.$i.'][field2]" value="'.$linha[$i]["field2"].'"></li>
</ul>';

echo '<br><br>
   <input type="submit" value="OK">
</form>';

if (isset($POST['teste'])) {
   $data = $_POST['teste']; 
   if ($data) {
    foreach ($data as $key => $value) {
        if (isset($value['id']) && !empty($value['id'])) {
            $query = "UPDATE table SET field =".$value['field'].",field2 =".$value['field2']." WHERE id= ".$value['id'];
            $query = rtrim($query, ", ");
            echo "<pre>$query";
        }
    }
}

}