0

I have the following code and I'm trying to update all the changes at once. But it did not work. Someone please help me!

Thanks!

<?php
if(isset($_POST['updateDays'])){
        $clock = $_POST['clock'];
        $id = $_POST['days_id'];
        $post_data=array(
            'dayweek_id' => esc_html($id),
            'opend_closed' => esc_html($clock)
        );
        var_dump($post_data);

        $wpdb->update( $table_days, $post_data, array( 'dayweek_id' => $id ), $format = null, $where_format = null );
    }
?>
<form class="wmtp-form-info" action="" method="post" enctype="multipart/form-data">
    <?php
        echo '<input type="hidden" name="days_id" id="days_id" value="'.esc_attr($info->dayweek_id).'" />';
        $get_data_dayweek = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $table_days"));
        foreach ($get_data_dayweek as $info) {
            echo $dayoftheweek;
            echo '<select name="clock">'; ?>
              <option value="<?php echo $opend_closed; ?>" <?php echo (isset($_SESSION['clock']) && $_SESSION['clock'] == $opend_closed) ? "selected" : "" ?> hidden><?php echo $opend_closed; ?></option>
              <option value="true"> Opened</option>
              <option value="false"> Closed</option>
            </select>
        <?php } ?>
<?php echo '<input class="button button-primary" type="submit" id="" name="updateDays" value="'.esc_html__('Update', $domain).'">'; ?>
</form>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.