โค้ด: เลือกทั้งหมด
<form action="check_save.php" method="POST" >
<tr>
<td valign="top">Relavant Keyfactor</td>
<td>
<?php
include("db_connect_edpex.php");
$sql = "SELECT * from keyfactor";
$objQuery = mysql_query($sql);
while($fetch = mysql_fetch_assoc($objQuery)){ ?>
<li>
<input type="checkbox" name="chkKey[]"
value="<?php echo $fetch["keyID"];?>"> <?php echo $fetch["keyName"];?>
</li>
<?php } ?>
<input type="submit" name="submit" id="submit" value="Submit"></td>
</tr>
[attachment=0]test3.png[/attachment][attachment=0]test3.png[/attachment][attachment=0]test3.png[/attachment]
</form>
โค้ด: เลือกทั้งหมด
<?php //save strength into db
include("db_connect_edpex.php");
if($_POST)
{
foreach($_POST['chkKey'] as $key=>$value)
{
$strID =5;
$sq1 = "INSERT INTO strengthkf(keyID, strID)
VALUES ('".$_POST['chkKey'][$key]."','".$strID."')"; //get keyID into strKF table
$qr= mysql_query($sq1) or die(mysql_error());
}
}
?>
<?php
$sql = "SELECT DISTINCT strengthkf.keyID FROM strengthkf where strengthkf.strID =5";
$objQuery = mysql_query($sql);
while($result = mysql_fetch_array($objQuery)){
echo $result["keyID"];
$sql1 = "SELECT * from keyfactor";
$obj = mysql_query($sql1);
while($fetch = mysql_fetch_array($obj)){ ?>
<li>
<input type="checkbox" name="chkKey[]"
value= "<?php $fetch["keyID"];?>" <?=($result["keyID"] == $fetch["keyID"] ? 'checked' : '')?>/>
<?php echo $fetch["keyName"];?>
</li>
<?php } ?>
<?php } ?>