I want to display the checkbox in while loop and nned to apply the CSS based on $status
value.If status=open in database open should be checked and vice versa for status='Close'
.I have CSS for each and every row based on id.I created random id in PHP variable $a
.
Now This is working only for status='open'
which is checked in if condition.
$a=0;
while($sfet=mysql_fetch_assoc($sql1))
{
echo ('<style>
.ck-button'.$a.' {
margin:0px;
background-color:#EFEFEF;
border-radius:4px;
border:1px solid #D0D0D0;
overflow:auto;
float:left;
}
.ck-button'.$a.' #label'.$a.' {
float:left;
width:4.0em;
}
.ck-button'.$a.' #label'.$a.' #span'.$a.' {
text-align:center;
padding:3px 0px;
display:block;
border-radius:4px;
}
.ck-button'.$a.' #label'.$a.' input {
position:absolute;
top:-20px;
}
input#o1'.$a.':checked + #span'.$a.' {
background-color: green;
color: #fff;
}
input#o2'.$a.':checked + #span'.$a.' {
background-color: red;
color: #fff;
}
input#o3'.$a.':checked + #span'.$a.' {
background-color: orange;
color: #fff;
}
.ck-button'.$a.' #label'.$a.':hover #o1'.$a.' + #span'.$a.' {
background-color:green;
}
.ck-button'.$a.' #label'.$a.':hover #o2'.$a.' + #span'.$a.' {
background-color:red;
}
.ck-button'.$a.' #label'.$a.':hover #o3'.$a.' + #span'.$a.' {
background-color:orange;
}
</style>');
$title=$sfet['title'];
$c_name=$sfet['c_name'];
$e_first_name=$sfet['e_first_name'];
$status=$sfet['status'];
$req_id=$sfet['req_id'];
$e_id=$sfet['e_id'];
echo '<tr><td><a href="broadcast_detail.php?req_id='.$req_id.'" class="astext">'.$title.'</a></td><td>'.$c_name.'</td><td>'.$e_first_name.'</td>';
$count="select * from resume where e_id='$e_id' and req_id='$req_id'";
$count1=mysql_query($count);
$num=mysql_num_rows($count1);
echo '<td>'.$num.'</td>';
if($status=='Open')
{
echo"<td><div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o1".$a."' onclick=demo('Open',".$req_id."); value='Open' checked><span id='span".$a."'>Open</span></label></div>";
echo"<div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o2".$a."' value='Close' onclick=demo('Close',".$req_id.");><span id='span".$a."'>Close</span></label></div>";
echo"<div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o3".$a."' value='Hold' onclick=demo('Hold',".$req_id.");><span id='span".$a."'>Hold</span></label></div></td><br><br>";
}
else if($status=='close'){
echo"<td><div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o1".$a."' onclick=demo('Open',".$req_id."); value='Open'><span id='span".$a."'>Open</span></label></div>";
echo"<div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o2".$a."' value='Close' onclick=demo('Close',".$req_id.");><span id='span".$a."' checked>Close</span></label></div>";
echo"<div class='ck-button".$a."'><label id='label".$a."'><input type='radio' name='sta_choice".$a."' id='o3".$a."' value='Hold' onclick=demo('Hold',".$req_id.");><span id='span".$a."'>Hold</span></label></div></td><br><br>";
}
$a++;
}