Php Loop In Js

[Solved] Php Loop In Js | Php - Code Explorer | yomemimo.com
Question : javascript php loop

Answered by : wild-warbler-wnxj0hnsacys

<?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>

Source : https://stackoverflow.com/questions/2663443/need-to-loop-through-a-php-array-in-javascript | Last Update : Mon, 03 Aug 20

Question : php loop in js

Answered by : delightful-dunlin-mh5zlk8pen60

<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>

Source : | Last Update : Tue, 14 Sep 21

Answers related to php loop in js

Code Explorer Popular Question For Php