我想将一个variable
值传递给一个url,但问题是当我第一次点击search button
时,该值不会出现,当第二次点击被触发时,将显示variable
值。我怎样才能解决这个问题?我认为这个错误是当我点击search button
这个页面令人耳目一新时。有人可以帮我解决这个问题吗?将变量值传递给URL
这里是我的代码:
<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>
这意味着在第一次点击你的'$ classid'变量空值和onl然后你给它分配一些后期值 – Thamilan
为什么不尝试发布请求然后在你的php中获取数据? – Jixone
为什么不使用“GET”方法发送值url? –