我将使用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");?>
对输出表进行了修正:
<?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);
?>
<table>
<?
while($row = mysqli_fetch_array($run)){
$s_name = $row['s_name'];
?>
<tr>
<td><?php echo $s_name;?></td>
</tr>
<?php }?>
</table>
<?php }?>
实际上只是name="go"
失踪了。
错误:
<input type="submit" value="go">
正确:
<input type="submit" value="go" name="go">
现在一切都好。