I WANT TO CLACULATE PER PERSON PRICE WHILE USER ENTERED THE NUMBER OF THE PERSON THEN THE AMOUNT IS AUTO CALCULATED.
THE COST IS DATABASE COLUMN AND I WANT TO ACCESS THAT COLUMN BUT I DONT KHOW WHAT IS THE ISSUE WHEN I DEFINE THE VARIABLE SHOW THE DATATYE ERROR.
BUT I FOUND THIS ERROR :Undefined variable $rs in C:xampphtdocstourismbook_form.php on line 43
0
HERE IS THE CODE
book_form.php
<?php
if(isset($_GET['id'])){
$packages = $conn->query("SELECT * FROM `packages` where md5(id) = '{$_GET['id']}',
md5(cost)='{$_POST['cost']}'");
if($packages->num_rows > 0){
foreach($packages->fetch_assoc() as $k => $v){
$k = $v;
global $cost;
$rs=print_r($row['Number_guest']*$row['cost']);
}
}
}
?>
<div class="container-fluid">
<form action="#" id="book-form">
<div class="form-group">
<input name="package_id" type="hidden" value="<?php echo $_GET['package_id'] ?>" >
<input name="cost" type="hidden" value="<?php echo $_GET['cost'] ?>" >
<b>Check in Date</b> <input type="date"class="form form-control" name="Check_in_date"
id="checkin" required="ture"/>
<b>Check out Date </b><input type="date"class="form form-control" name="Check_out_date" id="checkout" required="ture" />
<b>MobileNumber</b><input type="tel"class="form form-control" name="MobileNumber" pattern="[1-9]{1}[0-9]{9}" title="error message" id="mobil.no" required="ture" />
<b>Email </b><input type="email" class="form form-control" name="Email" id="email" required="" />
<!--new code-->
<b>Number of Persons</b><input type="hidden" name="Number_guest" value="<?php echo $row['Number_guest'];?>"/>
<input type="number" required tile="Number of Person" max="500" min="0"
name="Number_guest" class="form-control" value="1" style="text-align:center" id="Number of Guest"/>
<input type="hidden" name="payment" id="price"
value="<?php echo number_format($cost) ?>"/>
<br>
<span class="rounded-0 btn-flat btn-sm btn-primary d-flex align-items-center justify-content-between"><i class="fa fa-tag"></i> <span class="ml-1">
<?php echo number_format($rs) ?></span></span>
<!--<b>Number of Persons</b> <input type="number" class="form form-control" name=
"Number_guest" id="no.person" required="ture" />style="font-weight:bold;font-size:18px
<b>Ammount To Be Pay </b> <input type="text" class="form form-control" name="payment"
value=">">-->
<input type="submit" name="save" id="save" value="Save" class="form form-control" font-color="fff"/>
</div>
</form>
</div>
<script>
$(function(){
$('#book-form').submit(function(e){
e.preventDefault();
start_loader()
$.ajax({
url:_base_url_+"classes/Master.php?f=book_tour",
method:"POST",
data:$(this).serialize(),
dataType:"json",
error:err=>{
console.log(err)
alert_toast("an error occured",'error')
end_loader()
},
success:function(resp){
if(typeof resp == 'object' && resp.status == 'success'){
alert_toast("Book Request Successfully sent.")
$('.modal').modal('hide')
}else{
console.log(resp)
alert_toast("an error occured",'error')
}
end_loader()
}
})
})
})
</script>