PHP在JavaScript集成代码中的应用

PHP在JavaScript集成代码中的应用,javascript,php,mysql,phpmyadmin,timeline,Javascript,Php,Mysql,Phpmyadmin,Timeline,我尝试了几种选择,但都不起作用。。。。 我有密码 <script type="text/javascript"> $(document).ready(function() { <?php $sql = mysql_query("SELECT * FROM `info` WHERE `active` = '1' ORDER BY `id` DESC"); $id = 'id'; $title = 'title';

我尝试了几种选择,但都不起作用。。。。 我有密码

<script type="text/javascript">
                $(document).ready(function() {
    <?php
    $sql = mysql_query("SELECT * FROM `info` WHERE `active` = '1' ORDER BY `id` DESC");
    $id = 'id';
    $title = 'title';
    $content = 'content';
    while ($rows = mysql_fetch_assoc($sql)){
    ?>
                    var timeline_data = 
                   [
                        { 
                            title:    '<?php echo $rows[$title];  ?>',
                            content:  '<?php echo $rows[$content];  ?>'
                        }
                   ];
    <?php
     }
     ?>
                    var timeline = new Timeline($('#timeline'), timeline_data);
                    timeline.setOptions({
                       animation:       true,
                        lightbox:        true,
                        first_separator: true,
                        max:             2,
                        loadmore:        5,
                        separator:       'year',
                        columnMode:      'dual',
                        order:           'desc'
                    });
                    timeline.display();
                });

</script>

$(文档).ready(函数(){

$(文档).ready(函数(){

$(文档).ready(函数(){

看起来你一直在用一个新的在这个物体上写字…看起来你一直在用一个新的在这个物体上写字。。。。
 <script type="text/javascript">
                    $(document).ready(function() {
        <?php
        $sql = mysql_query("SELECT * FROM `info` WHERE `active` = '1' ORDER BY `id` DESC");
        $id = 'id';
        $title = 'title';
        $content = 'content';
    ?>
      var timeline_data =[];
       <?php while ($rows = mysql_fetch_assoc($sql)){
        ?>
                         timeline_data[] = 

                            { 
                                title:    '<?php echo $rows[$title];  ?>',
                                content:  '<?php echo $rows[$content];  ?>'
                            }
                       ;
        <?php
         }
         ?>
                        var timeline = new Timeline($('#timeline'), timeline_data);
                        timeline.setOptions({
                           animation:       true,
                            lightbox:        true,
                            first_separator: true,
                            max:             2,
                            loadmore:        5,
                            separator:       'year',
                            columnMode:      'dual',
                            order:           'desc'
                        });
                        timeline.display();
                    });

    </script>