I want to update data in mysql, when checkbox is enabled, but it is hard for me to put in the coding please help , here is screenshot
I have seen tutorial in this link but not able to fit the code in the below code->
<?php
require_once 'php/db.php';
// Display 10 most recent search items
$query = "SELECT * FROM data";
// $query1 = "SELECT * FROM data";
// The search
$result = $test_db->query($query);
// $result1 = $test_db->query($query1);
while($results = $result->fetch_array()) {
$result_array[] = $results;
}
foreach ($result_array as $result) {
// The output
echo '<tr>';
echo '<td class="small">'.$result['id'].'</td>';
//echo '<td class="small">'.$result['case'].'</td>';
echo'<td class="small" align="center"><form action="index.php" method="post">
<input type="checkbox" id="homepage" name="homepage" value="1" />
<input type="submit" name="formSubmit" value="Submit" /></form></td>';
echo '<td class="small">'.$result['location'].'</td>';
echo '<td class="small">'.$result['garbage'].'</td>';
echo '<td class="small">'.$result['name'].'</td>';
echo '<td class="small">'.$result['phone'].'</td>';
echo '<td class="small">'.$result['email'].'</td>';
echo '<td class="small">'.$result['dates'].'</td>';
echo '<td class="small">'.$result['times'].'</td>';
echo '</tr>';
}
$status = '0';
if(isset($_POST['homepage']) && $_POST['homepage'] == '1')
{
$status = $_POST['homepage'];
}
?>
Aucun commentaire:
Enregistrer un commentaire