Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate database column with checkbox
    text
    copied!<p>I am having trouble getting a column to update to yes if checked. I'm not getting any errors though. What am I doing wrong? I've tried a number of methods including leaving the array in and out of quotes. I know how to do this via a form w/ an email address but not checkboxes. I also know how to delete rows from a database using checkboxes. But not update...</p> <pre><code> &lt;?php $id = $_GET['id']; $select = mysql_query("SELECT * FROM volsMain WHERE ID = '$id'"); $data = mysql_fetch_array($select); ?&gt; &lt;?php $query="SELECT * FROM volsMain ORDER BY shift_times, position"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)){ ?&gt; &lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt; &lt;input type="hidden" name="id" value="&lt;?php echo $id; ?&gt;" /&gt; &lt;input type="checkbox" name="checkinsat" value="yes"&lt;?php if($data['checkinsat'] == 'yes') echo 'checked'; ?&gt;/&gt; &lt;input type="submit" &gt; &lt;/form&gt; &lt;?php if ($row['saturday'] === 'A.M.') { echo '&lt;span class="amShift"&gt;'; } else if ($row['saturday'] === 'P.M.') { echo '&lt;span class="pmShift"&gt;'; } else { echo '&lt;span&gt;'; } echo "SATURDAY:" . $row['saturday'] . '&lt;/span&gt;&lt;br /&gt;'; if ($row['sunday'] === 'A.M.') { echo '&lt;span class="amShift"&gt;'; } else if ($row['sunday'] === 'P.M.') { echo '&lt;span class="pmShift"&gt;'; } else { echo '&lt;span&gt;'; } echo "SUNDAY:". $row['sunday'] . '&lt;/span&gt;&lt;br /&gt;'; echo "&lt;br /&gt;SHIRT SIZE:&lt;h2&gt;" . $row['shirt'] . "&lt;/h2&gt;"; echo "&lt;br /&gt;VOLUNTEER NAME:&lt;h2&gt;" . $row['agreeName'] . "&lt;/h2&gt;"; echo "&lt;p&gt;Assigned as a volunteer for:&lt;br /&gt;" . $row['position'] . "&lt;/p&gt;"; echo "&lt;p&gt;Shift times are scheduled for:&lt;br /&gt;" . $row['shift_times'] . "&lt;/p&gt;"; echo "&lt;p&gt;Shifts have been confirmed:&lt;br /&gt;" . $row['confirmed'] . "&lt;/p&gt;"; echo "&lt;p&gt;Checked in Friday:&lt;br /&gt;" . $row['checkinfri'] . "&lt;/p&gt;"; echo "&lt;p&gt;Checked in Saturday:&lt;br /&gt;" . $row['checkinsat'] . "&lt;/p&gt;"; echo "&lt;p&gt;Checked in Sunday:&lt;br /&gt;" . $row['checkinsun'] . "&lt;/p&gt;"; } ?&gt; &lt;?php $checkSAT = isset($_POST['checkinsat']) ? "yes" : "no"; $updateSat = mysql_query("UPDATE volsMain SET checkinsat = '$checkSAT' WHERE ID = '$id'"); $query = mysql_query($updateSat); $result = mysql_query($query); echo "&lt;p&gt;" . print_r($checkSAT) . "&lt;/p&gt;"; ?&gt; </code></pre>
 

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