0

I'm new here, I got problem with my script when display page flip using turn.js. My page is come from mysql database store it in json format then parse to array in JavaScript to view by turn.js

Here's my code :

<body>
<?php
$json_array = Array();

include("setdb.php");
$query="select * from catalogue_page where catalogue_id='5'";    
$result=mysql_query($query);
$totalrec=mysql_num_rows($result);


 while ($hasil=mysql_fetch_array($result)){

    $data=  "images/pages/small/".$hasil['img_file_small'];

 array_push($json_array, $data);  
 }


 $json_array2 = array();

 $query="select * from catalogue_page where catalogue_id='5'";    
 $result=mysql_query($query);

 while ($hasil=mysql_fetch_array($result)){

    $data="images/pages/large/".$hasil['img_file_large'];

    array_push($json_array2, $data);  
  }

?>

<div class="magazine-viewport">
<div class="container">
  <div class="magazine">
  </div>
</div>
</div>

<script type="text/javascript">
var page_image = Array();
var page_image_large = new Array();

page_image = JSON.parse( '<?php echo json_encode($json_array)?>' );

page_image_large = JSON.parse( '<?php echojson_encode($json_array2)?>'   



 );

......
......
 next script from turn.js
</script>

That script showing page starting from 1 coloumn not starting from 0 column

in browser turn.js starting show the page from images/pages/small/2_5.jpg not images/pages/small/1_5.jpg

my json parse is

( '["images\/pages\/small\/1_5.jpg","images\/pages\/small\/2_5.jpg","images\/pages\/small\/3_5.jpg","images\/pages\/small\/4_5.jpg","images\/pages\/small\/5_5.jpg","images\/pages\/small\/6_5.jpg"]' ); 

0 coloumn is images\/pages\/small\/1_5.jpg
1 coloumn is images\/pages\/small\/2_5.jpg .... next coloumn

4

1 回答 1

0

最后我是正确的我的脚本和 turnjs 显示页面的魅力在这里我的正确脚本:

<script type="text/javascript">
var page_image = new Array();
var page_image_large = new Array();

var tampung1 = JSON.parse( '<?php echo json_encode($json_array)?>');
var tampung2 = JSON.parse( '<?php echo json_encode($json_array2)?>');
var j=1;

for(i=0;i<<?php echo $totalrec?>;i++)
{
page_image[j] = tampung1[i];
page_image_large[j] = tampung2[i];
j++
}

 .....
 next turnjs script
</script>

无论如何感谢您的关注。

于 2015-10-25T12:23:53.617 回答