I'm trying to update multple queries but the update is not working.

here is the code....

if (isset($_POST['btnSub']))
 // Preset counter $p and switch $sw to 0

 // Create UPDATE queries
 foreach($_POST["entry"] as $data)
  $sql[$p]="UPDATE major SET ";
  foreach($data as $key => $value)

   // Save first $key => $value pair for WHERE clause

   // Setup fields to update

  // Remove last comma from query

  // Add WHERE clause to query
  $sql[$p].=" WHERE ".$w;

  // Reset switch and increment counter for next query

 // Setup counter to execute queries

 // Loop through UPDATE queries
  mysql_query($sql[$p]) or die(mysql_error());

// Setup query to fetch data from database table
$sql = "SELECT place,team,wl,gb,pcage,rs,ra,ags FROM major";
$results=mysql_query($sql) or die(mysql_error());

<!-- Create form and populate table -->
<form action="#" method="POST">
 echo '<tr>
       <td><input name="entry['.$p.'][place]" type="text" value="'.$row["place"].'"/></td>
       <td><input name="entry['.$p.'][team]" type="text" value="'.$row["team"].'"/></td>
       <td><input name="entry['.$p.'][wl]" type="text" value="'.$row["wl"].'"/></td>
       <td><input name="entry['.$p.'][gb]" type="text" value="'.$row["gb"].'"/></td>
       <td><input name="entry['.$p.'][pcage]" type="text" value="'.$row["pcage"].'"/></td>
       <td><input name="entry['.$p.'][rs]" type="text" value="'.$row["rs"].'"/></td>
       <td><input name="entry['.$p.'][ra]" type="text" value="'.$row["ra"].'"/></td>
       <td><input name="entry['.$p.'][ags]" type="text" value="'.$row["ags"].'"/></td>

<!-- Submit form to update database table. -->
<td colspan=8><input type="submit" name="btnSub" value="Submit"></td>

The query shows but i need to update it.

Member Avatar for amigura
for ($i = 0; $i <= 10; $i++) {
$sql = "UPDATE major SET place ='".$entry[$i][place]."',team ='".$entry[$i][team]."',wl ='".$entry[$i][wl]."',gb ='".$entry[$i][gb]."',pcage ='".$entry[$i][pcage]."',rs ='".$entry[$i][rs]."',ra ='".$entry[$i][ra]."',ags ='".$entry[$i][ags]."' 
where id = 'watever this is supposed to be'";
$query = mysql_query($sql) or die("Cannot query the database.<br />" . mysql_error());
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.