PHP MySQL search using radio option
<?php include 'includes/config.php'; ?>
<?php
if(isset($_POST['submit'])){
$pickup=isset($_POST['pickup'])?$_POST['pickup']:'';
$dropoff=isset($_POST['dropoff'])?$_POST['dropoff']:'';
$traveltype=isset($_POST['traveltype'])?$_POST['traveltype']:'';
$sql = "SELECT * from availablecabs where pickup='$pickup' AND dropoff='$dropoff' AND traveltype='$traveltype'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
?>
<?php
while($row = $result->fetch_assoc()) {
$indica=$row['indica'];
}
} else {}
}
?>
<form class="input-daterange" data-date-format="M, d" method="POST" action="car-search.php">
<div class="form-group form-group-icon-left"><i class="fa fa-map-marker input-icon input-icon-hightlight"></i>
<label>Pick Up Location</label>
<select class="form-control" placeholder="Pick-up Location" type="text" name="pickup" >
<option value="">Pick-up Location</option>
<option value="satna" selected>Satna, MP</option>
</select>
</div>
<div class="form-group form-group-icon-left"><i class="fa fa-map-marker input-icon input-icon-hightlight"></i>
<label>Drop Off Location</label>
<select class="form-control" placeholder="Drop-Off Location" type="text" name="dropoff">
<option value="" <?php if (isset($dropoff) && $dropoff=="") echo ' selected';?>>Same as Pickup</option>
<option value="satna" <?php if (isset($dropoff) && $dropoff=="satna") echo ' selected';?>>Satna, MP</option>
<option value="chitrakoot" <?php if (isset($dropoff) && $dropoff=="chitrakoot") echo ' selected';?>>Chitrakoot, MP</option>
</select>
</div>
<div>
<div class="form-group">
<label class="radio-inline"><input type="radio" name="traveltype" value="day" checked <?php if (isset($traveltype) && $traveltype=="day") echo ' checked';?>>FullDay</label>
<label class="radio-inline"><input type="radio" name="traveltype" value="halfday" <?php if (isset($traveltype) && $traveltype=="halfday") echo ' checked';?>>HalfDay</label>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Update Search" name="submit"/>
</form>
<?php
if(isset($_POST['submit'])){
$pickup=isset($_POST['pickup'])?$_POST['pickup']:'';
$dropoff=isset($_POST['dropoff'])?$_POST['dropoff']:'';
$traveltype=isset($_POST['traveltype'])?$_POST['traveltype']:'';
$sql = "SELECT * from availablecabs where pickup='$pickup' AND dropoff='$dropoff' AND traveltype='$traveltype'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
?>
<?php
while($row = $result->fetch_assoc()) {
$indica=$row['indica'];
}
} else {}
}
?>
<form class="input-daterange" data-date-format="M, d" method="POST" action="car-search.php">
<div class="form-group form-group-icon-left"><i class="fa fa-map-marker input-icon input-icon-hightlight"></i>
<label>Pick Up Location</label>
<select class="form-control" placeholder="Pick-up Location" type="text" name="pickup" >
<option value="">Pick-up Location</option>
<option value="satna" selected>Satna, MP</option>
</select>
</div>
<div class="form-group form-group-icon-left"><i class="fa fa-map-marker input-icon input-icon-hightlight"></i>
<label>Drop Off Location</label>
<select class="form-control" placeholder="Drop-Off Location" type="text" name="dropoff">
<option value="" <?php if (isset($dropoff) && $dropoff=="") echo ' selected';?>>Same as Pickup</option>
<option value="satna" <?php if (isset($dropoff) && $dropoff=="satna") echo ' selected';?>>Satna, MP</option>
<option value="chitrakoot" <?php if (isset($dropoff) && $dropoff=="chitrakoot") echo ' selected';?>>Chitrakoot, MP</option>
</select>
</div>
<div>
<div class="form-group">
<label class="radio-inline"><input type="radio" name="traveltype" value="day" checked <?php if (isset($traveltype) && $traveltype=="day") echo ' checked';?>>FullDay</label>
<label class="radio-inline"><input type="radio" name="traveltype" value="halfday" <?php if (isset($traveltype) && $traveltype=="halfday") echo ' checked';?>>HalfDay</label>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Update Search" name="submit"/>
</form>
Comments
Post a Comment