javascript php loop
<?php
$s=array('a','b','c','d','e','f');
$s_to_json=json_encode((array)$s);
?>
<script type="text/javascript">
var fromPHP=<? echo $s_to_json ?>;
for (i=0; i<fromPHP.length; i++) {
yourValue=fromPHP[i];
}
</script>
javascript php loop
<?php
$s=array('a','b','c','d','e','f');
$s_to_json=json_encode((array)$s);
?>
<script type="text/javascript">
var fromPHP=<? echo $s_to_json ?>;
for (i=0; i<fromPHP.length; i++) {
yourValue=fromPHP[i];
}
</script>
php loop in js
<script>
<?php
$eq = "SELECT * FROM events ORDER BY event_id desc";
//store the result of the query in a variable called $result
$resulteq=mysqli_query($connection, $eq);
while($events=mysqli_fetch_assoc($resulteq)) {
$event_title = $events['event_title'];
$start_time = $events['event_start_time'];
$f_start_time = date_create($start_time);
$event_start_time = date_format($f_start_time, 'c');?>
calendar.addEvent({
title: '<?=$event_title?>',
start: '<?=$event_start_time?>',
url: '../../../main/home.php',
})
<?php }?>
calendar.render();
});
</script>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us