refer to in_array
<?php
if(isset($_GET["poscon"])) {
$_SESSION["poscon"] = $_GET["poscon"];
$dr=$_SESSION['poscon'];
if(isset($_POST['submit'])) {
if(!empty($_GET['poscon']))
$_SESSION['poscon'] = $_POST['poscon'];
$part=$_GET["poscon"];
}
$poscon=mysqli_real_escape_string($link,$_GET['poscon']);
$p = mysqli_query($link,"select distinct PossibleCondition,Symptoms from healthguide where Subpart like '%$poscon%' and PossibleCondition REGEXP '^[N-Z].*$' Order by PossibleCondition ");
while($r=mysqli_fetch_array($p)) {
$pc=$r["PossibleCondition"];
$sym=$r["Symptoms"];
if(isset($_POST) && isset($_POST['poscon']) && in_array($pc,$_POST['poscon']))
$strIsChecked='checked="checked"';
else
$strIsChecked=null;
echo '<tr>';
echo '<td><input type="checkbox" '.$strIsChecked.' title ="'.$sym.'" name="poscon[]" value ="'.$pc.'"></td>';
echo '<td>'.$pc.'</td>';
echo '</tr>';
}
}
?>
0
solved Retain Checked the checkbox inside While