douzhu1188 2016-05-23 07:59
浏览 44

从php到javascript获取变量

What am I trying to do? To finish my final school year I have to script a code which shows a diashow.

Every slide has their own displaytime, so the variable has to change automatically when the timer hits the value.

These time information are in the variable array[$i]["Anzeigedauer"]

Variable $array[] -> all data from database stored in here

When I try to take this variable in javascript see var ad it outputs output Output as often as there are data in the database

Ps. I am quite new in scripting so if any other informations are required, please let me know

<?php

  while ($dsatz = mysqli_fetch_assoc($query))
    {
      array[] = $dsatz;
      $count = count($array);
    }
    
  
for ($i = 0; $i <= $count-1: $i++)
  {
    echo $array[$i]["Anzeigedauer"];
    $zeit= $array[$i]["Anzeigedauer"];
  
    echo "<li><h1>", $array[$i]["Titel"] . "</h1><br>"
    ."<p id='inhalt'>", $array[$i]["Titel"] . "</p><br></li>";
  }
  
  mysqli_close($con);
  
?>

<script>
  var ad = <?php echo json_encode($array[1]["Anzeigedauer"]);?;
  
  // var sek = "<?php echo $array[$i]["Anzeigedauer"]?>";
  //var mili= sek*1000;
  
  ad.toString(); 
  
  $("#foo3")-carouFredSel({
    items: 1,
    auto: 1000 // need variable here!!!
    scroll: 1,
    pagination : "#foo3_pag"
    });
  </script>

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了
    • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
    • ¥188 需要修改一个工具,懂得汇编的人来。
    • ¥15 livecharts wpf piechart 属性
    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了