这与我在 search.php 中提出的另一个问题“(在搜索框上获取结果)”有关。我在执行搜索框的结果时做了一些更改,如下所示,这将在复选框形式。
foreach($results as $result) {
echo "<input type = 'checkbox' name ='studid[]' value='".$result['studId']." onchange='get_searched_value()''>";
echo ' ', $result['fname'],' ',$result['mname'],' ',$result['lname'],'<br/>';
}
我创建了另一个表单名称 regitrcand.php,我只在此处包含表单 search.php。
<form method="post" name="searched" action="registercand.php">
<?php require_once('search.php'); ?>
<input type="submit" name="select" value="Select">
</form>
//here i want to get the value of my search.php(foreach result) from the checked/selected result as i click the select button..
<?php
if(isset($_POST['select'])){
$studid = $_POST['studid'];
$position = $_POST['position'];
echo $studid;
echo $position;
}
echo "<table>";
echo "<tr><td>Running for:</td></tr><tr><td><select name='position'>
<option value='0' style='font-size: 1em;'>---SELECT---</option>
<option value='1'>Chairman</option>
<option value='2'>Vice Chairman</option>
<option value='3'>Secretary</option>
<option value='4'>Treasurer</option>
<option value='5'>Auditor</option>
<option value='6'>Bus. Manager</option>
<option value='7'>P.I.O</option>
<option value='8'>Councilor</option>
<option value='9'>CCEITE Representative</option>
<option value='10'>CCJE Representative</option>
<option value='11'>CAS Representative</option>
<option value='12'>CTE Representative</option>
<option value='13'>CBMA Representative</option></td></tr> ";
$yrnw = date("Y");
$lyr = 1;
$lstyr = $yrnw - $lyr ;
$sy = 10 + $yrnw;
echo "<tr><td>SY:</td></tr><tr><td><select name= 'sy'>";
for($i=$yrnw; $i<$sy ; $i++){
$lst = $i -1;
echo "<option value='$i'>$lst-$i<br/></option>";
}
echo "</select></td></tr>
//here i put save button for another purpose, the result i selected from above will be save into my database.
<tr><td><input type='button' name='save' value='Save'/></td></tr>
</table>
";
?>
流程是这样的。从我的搜索框中执行所有结果后,我将检查学生的姓名以选择候选人(2 个或更多)并单击选择按钮,然后将选择的名称设置为他/她的职位选择一个选项,然后单击保存按钮保存在我的表中。我怎么可能得到我的复选框的值并保存按钮?请帮助,并给我一些建议....