I have created a dropdown in plain php that really works and I want it to apply also in my codeigniter project but I don't know how. I tried but the code does not work. This is the plain php to be converted to codeigniter: The main page:
<select id="operationName" name="operationName">
<option value="">-SELECT-</option>
<?php while($rs = $query->fetch())
{
extract($rs);
?>
<option value="<?php echo $OperationName;?>"><?php echo $OperationName;?> </option>
<?php
}
?>
</select>
<input type="text" id="deldays" name="deldays" >
<div id="deldays"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#operationName').change(function(){
$.get('trial.php',{q:$(this).val()},function(data){
$('#deldays').val(data);
});
});
});
and here is the php function that is being called:
if(isset($_GET['q']))
{
$days = $_GET['q'];
try{
$qry = $conn->prepare("SELECT * FROM operation WHERE OperationName = :opt");
$qry->bindParam(':opt',$days);
$qry->execute();
}
catch(PDOException $e)
{
echo $e->getMessage();
exit();
}
while($rs = $qry->fetch())
{
extract($rs);
echo $DeliveryDays;
}
}