while ($div=mysql_fetch_array($query4, MYSQL_ASSOC)) {

    //$div - shows all the entries    

$row22=mysql_fetch_array($query2, MYSQL_ASSOC);

//row22 - shows all the entries that should be checked

$name= array($div['date_id']);
$datess=$row22['date_id'];

if (in_array($datess, $name, true)) {

echo '<input type="checkbox" value="' . $div[date_id] .'" checked>' . $div[date] . '</option>';

}else{

echo '<input type="checkbox" value="' . $div[date_id] .'">' . $div[date] . '</option>';

}

1. when echo $row22 shows only the entries that should be checked - working good
2. checkboxes show checked if only the first checkbox is selected or all 3 - if a combination is selected, it is all blank.


notes:
$query2 checks which checkboxes the user has selected
wants to verify it against all the checkboxes in $query4
than mark $query2 checkboxes as checked.

Any ideas appricated
Thank you
isaiaha is online now Flag Post Reply With Quote

solved

while ($div=mysql_fetch_assoc($query4)) {  //$query4 contains all the checkboxes
    $checked = false;

    while($row22=mysql_fetch_assoc($query2)) {//query2 contains the checked checkboxes
         if($div['date_id'] == $row22['date_id']) {

              $checked = true;
			 
         }
     }

    //display the checkbox
    if($checked) {
		
		     //display checkbox with checked="checked"
			 echo '<input type="checkbox" value="' . $div[date_id] .'" checked>' . $div[date] . '</option>';
    } else {
            //display checkbox without being checked
			echo '<input type="checkbox" value="' . $div[date_id] .'">' . $div[date] . '</option>';
    }

    //reset the pointer in $row22 back to the start
    mysql_data_seek($query2,0);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.