I have a php file and in that file it consist of a code like below
<?php if ($totalBookings !== 1) { ?>
<div class="modal-body mundana-login-wrapper">
<label>Are you sure you want to remove this booking?</label>
</div>
<div class="modal-footer">
<button type="button" onclick="removeBooking()" id="remove_booking" class="mundana-button primary ghost" data-dismiss="modal">Yes</button>
<button type="button" onclick="cancelRemoveBooking();" class="mundana-button ghost" data-dismiss="modal">Cancel</button>
</div>
<?php } else { ?>
<div class="modal-body mundana-login-wrapper">
<label>You are about to remove the only selected room. Do you want to remove?</label>
</div>
<div class="modal-footer">
<button type="button" onclick="removeBooking();" id="remove_booking" class="mundana-button primary ghost" data-dismiss="modal">Yes</button>
<button type="button" onclick="cancelRemoveBooking();" class="mundana-button ghost" data-dismiss="modal">Cancel</button>
</div>
<?php } ?>
In the same file i have a code inside script tags as follows
<script>
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
function updateCookie(){
$totalBookings = getCookie('total_bookings');
}
</script>
I want to access the $totalBookings
which is declared inside the script tags, to the if condition i have used in the php file. <?php if ($totalBookings !== 1) { ?>
I cannot access that variable like that and i'm new to php. How can i access the $totalBooking
variable which is inside the script tags to my php code.?