Reputation: 88
I want to pass a variable
value to an url but the problem is when I first clicked the search button
the value doesn't appear and when the second clicked is triggered the variable
value is shown. How can i fix this? I think the fault is when i click the search button
the page is refreshing. Can someone help me about this?
here's my code:
<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>
Upvotes: 1
Views: 53
Reputation: 673
in your
<form action="student.php?classid=<?php echo $classid;?>" method="post">
change it to
<form action="student.php" method="post">
Upvotes: 1