我将使用select选项从数据库中获取数据,但是没有任何显示任何输出...任何人都可以发现问题是什么问题,我的代码还是我们采用了错误的技术? 这是我的下面的代码
<div class="heading" style="margin-bottom:10px; float:left; color:black;">Select Records</div>
<div style="float:right; color:black;">
<form >
<select name="session" >
<option value='Null'><b>Select Session</b></option>
<?php
$status_on = 'no';
$query1 = "select * from sessions where
status='$status_on'";
$run = mysqli_query($con,$query1);
while($row=mysqli_fetch_array($run)){
$id = $row['session_id'];
$p_id = $row['program_id'];
$session_name = $row['session_name'];
echo "
<option value='$id'><b>$session_name</b></option>";
}
?>
</select>
<input type="submit" value="go" />
<div style="color:red;">
<?php
if(isset($_GET['go'])){
$session = $_GET['session'];
$sql = "select * from students where session_id like'%$session%'";
//$sql = "select * from students where session_id='$session%'";
// also tried
$run = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($run)){
$s_name = $row['s_name'];
?>
<table>
<tr>
<td><?php echo $s_name;?></td>
</tr>
<?php }?>
<?php }?>
</table>
</div>
</form>
</div>
<?php include("footer.php");?>
答案 0 :(得分:0)
对输出表进行校正:
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<i class="fas fa-question-circle"></i>
答案 1 :(得分:-1)
实际上只有name="go"
丢失了。
错误:
<input type="submit" value="go">
正确:
<input type="submit" value="go" name="go">
现在一切正常。