mercredi 23 décembre 2015

Showing checked checkbox from database for editing

I am trying to show the checked checkboxes from database which are added during inserting user.But when I am editing that user I want to show those checkboxes as checked.How to do that.Here is my code for edit.

$edit = true;
$id = $_REQUEST['id'];

$userEdit = $executeQuery->oneRowCondition("user_master", "user_id='$id'");

if(isset($_REQUEST['subMitBtn'])){

    @$username = $_REQUEST['user_name'];
    @$compID = $_REQUEST['compID'];
    @$email=$_REQUEST['email'];
    @$password=$_REQUEST['password'];
    @$q1=explode(',',$_POST['q1']);

    @$q2=$q1.",";


    $insertUser = mysqli_query($conn, "UPDATE user_master SET 
         user_name = '$username', user_email='$email', user_password='$password',user_module='$q2' where  user_id = '$compID' ");
    echo "UPDATE user_master SET 
         user_name = '$username', user_email='$email', user_password='$password',user_module='$q2' where  user_id = '$compID' ";     


}

And HTML code is:

<label class="col-sm-2 control-label">Modules</label>
<div class="col-sm-3">

<input type="checkbox" id="q1[]" name="q1[]" value="Dashboard" > Dashboard<br>

<input type="checkbox" id="q1[]" name="q1[]" value="Order Entry"> Order Entry <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Status"> Status <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Customers"> Customers <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Shipping Company" > Shipping Company <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Shipping Rates" > Shipping Rates <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Retailer"> Retailer <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Marketing"> Marketing <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Sales Report"> Sales Report <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Inward Report"> Inward Report <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Outward Report"> Outward Report <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Users & Roles"> Users & Roles <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Change Password"> Change Password <br>

<input type="checkbox" id="q1[]" name="q1[]" value="Email Settings"> Email Settings <br>




Aucun commentaire:

Enregistrer un commentaire