Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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

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

PREVIOUS NEXT
Code Example
Php :: create foreign key phpmyadmin 
Php :: send mail test from laravel 
Php :: laravel php artisan tinker test email 
Php :: branch from other branch 
Php :: php month single digit 
Php :: laravel json search 
Php :: how to convert array to string with commas in php 
Php :: Target class [Controller] does not exist. 
Php :: laravel with where has 
Php :: laravel assign class dynamically if condition true 
Php :: php explode multiple delimiters 
Php :: php sql query where in array 
Php :: delete record using laravel 
Php :: php get first 10 elements of array 
Php :: laravel weekly data 
Php :: array_unique multidimensional php 
Php :: php setinterval 
Php :: how-to-call-ajax-in-wordpress 
Php :: enum in laravel migration 
Php :: php 7 strict mode 
Php :: laravel query select from table where id != to another table id 
Php :: php get tempfile 
Php :: get values from text file php 
Php :: password_hash 
Php :: laravel foreign key constraint 
Php :: laravel sail publish 
Php :: install php-8 
Php :: laravel deploy without moving public directory 
Php :: php convert string to int in array 
Php :: remove non-uppercase character php 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =