将变量值传递给URL

时间:2017-08-21 05:33:43

标签: php html

我想将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>

enter image description here

1 个答案:

答案 0 :(得分:1)

中的

<form action="student.php?classid=<?php echo $classid;?>" method="post">

将其更改为

<form action="student.php" method="post">
相关问题