<form action="CHECKBOX.php" method="post">
<input type="hidden" name="color" value="0"/>
<?php
include('function.php');
$name = isset($_POST['stick'])?$_POST['stick']:NULL;
if(isset($_POST['stick'])){
foreach ($name as $stk){
//checkboxes
$stk = implode(',', $name);
//echo $stk;
$query = "SELECT * FROM machine_and_equipments where MENo IN('$stk')";
$result = mysql_query($query) or die (mysql_error());
while($query_row = mysql_fetch_assoc($result)){
$controlnumber = $query_row['MENo'];
$assetname = $query_row['machine_equipments_name'];
$location = $query_row['Location'];
?>
<br>
<table>
<tr>
<td>
<?php echo $controlnumber;?>
</td>
<td>
<?php echo $assetname;?>
</td>
<td>
<?php echo $location;?>
</td>
</td>
</tr>
</table>
<?php }}}
?>
KMP-AC1-001<input type="checkbox" name="stick[]" id="stick" value="KMP-AC1-001"><br />
KMP-AC2-002<input type="checkbox" name="stick[]" id="stick" value="KMP-AC2-002"><br />
KMP-AC3-003<input type="checkbox" name="stick[]" id="stick" value="KMP-AC3-003"><br />
KMP-AC4-004<input type="checkbox" name="stick[]" id="stick" value="KMP-AC4-004"><br />
KMP-RF1-005<input type="checkbox" name="stick[]" id="stick" value="KMP-RF1-005"><br />
KMP-RF2-006<input type="checkbox" name="stick[]" id="stick" value="KMP-RF2-006"><br />
KMP-EL2-009<input type="checkbox" name="stick[]" id="stick" value="KMP-EL2-009"><br />
<input type="submit" value="submit">
</form>
答案 0 :(得分:0)
修改以下行:
$stk = "'" . implode("','", $name) . "'";
//echo $stk;
$query = "SELECT * FROM machine_and_equipments where MENo IN($stk)";
答案 1 :(得分:0)
<form action="CHECKBOX.php" method="post">
<input type="hidden" name="color" value="0"/>
<?php
include('function.php');
$name = isset($_POST['stick'])?$_POST['stick']:NULL;
if(isset($_POST['stick'])){
//checkboxes
$stk = "'" . implode("','", $name) . "'";
echo $stk;
$query = "SELECT * FROM machine_and_equipments where MENo IN($stk)";
$result = mysql_query($query) or die (mysql_error());
while($query_row = mysql_fetch_assoc($result)){
$controlnumber = $query_row['MENo'];
$assetname = $query_row['machine_equipments_name'];
$location = $query_row['Location'];
?>
<br>
<table>
<tr>
<td>
<?php echo $controlnumber;?>
</td>
<td>
<?php echo $assetname;?>
</td>
<td>
<?php echo $location;?>
</td>
</td>
</tr>
</table>
<?php }}
?>
KMP-AC1-001<input type="checkbox" name="stick[]" id="stick" value="KMP-AC1-001"><br />
KMP-AC2-002<input type="checkbox" name="stick[]" id="stick" value="KMP-AC2-002"><br />
KMP-AC3-003<input type="checkbox" name="stick[]" id="stick" value="KMP-AC3-003"><br />
KMP-AC4-004<input type="checkbox" name="stick[]" id="stick" value="KMP-AC4-004"><br />
KMP-RF1-005<input type="checkbox" name="stick[]" id="stick" value="KMP-RF1-005"><br />
KMP-RF2-006<input type="checkbox" name="stick[]" id="stick" value="KMP-RF2-006"><br />
KMP-EL2-009<input type="checkbox" name="stick[]" id="stick" value="KMP-EL2-009"><br />
<input type="submit" value="submit">
</form>