Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP prepared statement insert from a loop of data
    primarykey
    data
    text
    <p>Any ideas as to why my data isn't being updated? Is their something fundamentally wrong with how I'm writing my prepared statement? </p> <p><strong>The form:</strong></p> <pre><code>while($log_dates = mysqli_fetch_assoc($q_log_dates_result)) { echo "&lt;tr&gt;"; echo "&lt;input type='hidden' name='data[][log_dates_ID]' value='" . $log_dates['log_dates_ID'] . "'/&gt;"; echo "&lt;td&gt;&lt;input type='text' name='data[][week_date]' value='" . $log_dates['week_date'] . "' /&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;input type='text' name='data[][crew_chief]' value='" . $log_dates['crew_chief'] . "' readonly /&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;input type='text' name='data[][monday_crew]' value='". $log_dates["monday_crew"] ."'/&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; } // end while loop </code></pre> <p><strong>PHP:</strong></p> <pre><code>if (isset($_POST['submit'])) { $stmt = $connection-&gt;stmt_init(); if($stmt-&gt;prepare("UPDATE log_dates SET (week_date, crew_chief, monday_crew) VALUES (?, ?, ?) WHERE log_dates_ID = ?")) { // Bind your variables to replace the ?s $stmt-&gt;bind_param('sssi', $week_date, $crew_chief, $monday_crew, $log_dates_ID); $returnedData = $_POST['data']; for($i=0;$i&lt;count($returnedData);$i+=4){ $log_dates_ID = $returnedData[$i]['log_dates_ID']; $week_date = $returnedData[$i+1]['week_date']; $crew_chief = $returnedData[$i+2]['crew_chief']; $monday_crew = $returnedData[$i+3]['monday_crew']; $stmt-&gt;execute(); } // Close statement object $stmt-&gt;close(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload