0

我有以下 php 代码。如何修改复选框以在我的数据库中保留作为“勾号”的选定值,然后再次打印回来?

<?php


if ( isset($_GET['success']) === true && empty($_GET['success'])===true ){
echo'Updated Sucessfuly!';?>

<?php 
    }else{

    if( empty($_POST) === false  &&  empty($errors) === true ){

    $update_data_profile_career = array(
                'Consulting' => $_POST['Consulting'],
                'user_id' => $session_user_id,
                      );
                update_user_profile_career($session_user_id, $update_data_profile_career);

                header('Location: profile_update_career_goal.php?success');                             
                exit();


    }else if ( empty($errors) === false ){
                        echo output_errors($errors);
                        echo'</br></br>';
    }


?>

<input type="checkbox" name="Consulting[]" value="<?php echo $user_data_profile_career['Consulting'];     ?>" />Consulting
4

2 回答 2

0
<?php echo $user_data_profile_career['Consulting']?' checked':''; ?>
于 2013-04-13T15:16:22.093 回答
0

您必须检查 db 中的值并checked='checked'用于检查复选框

<input type="checkbox" name="Consulting[]" value="<?php echo $user_data_profile_career['Consulting'];     ?>" 
<?php isset($user_data_profile_career['Consulting']) ? "checked='checked'":'' ?> />Consulting
于 2013-04-13T15:19:55.770 回答