我想将variable
值传递给网址,但问题是,当我第一次点击search button
时,该值未显示,而第二次点击则触发了variable
值显示。我怎样才能解决这个问题?我认为错误是当我点击search button
页面刷新时。有人可以帮我解决这个问题吗?
这是我的代码:
<div class="form-inline form-padding">
<form action="student.php?classid=<?php echo $classid;?>" method="post">
<input type="text" class="form-control" name="search" placeholder="Search by ID or Name">
<select name="subject" class="form-control" required>
<option value="">Select Subject...</option>
<?php while($row = mysql_fetch_array($mysubject)): ?>
<option value="<?php echo $row['id']?>" <?php if($row['id']==$classid) echo 'selected'; ?>><?php echo $row['subject'];?></option>
<?php endwhile; ?>
</select>
<button type="submit" name="submit" id="submit" class="btn btn-primary"><i class="fa fa-search"></i> Search</button>
<a href="print.php?classid=<?php echo $classid; ?>" target="_blank"><button type="button" name="submit" class="btn btn-success"><i class="fa fa-print"></i> Print</button></a>
</form>
</div>
答案 0 :(得分:1)
中的
<form action="student.php?classid=<?php echo $classid;?>" method="post">
将其更改为
<form action="student.php" method="post">