アットウィキロゴ

php ぼおk

<html>
<head>
<meta charset="utf-8"/>   
<title>book</title>    
<script src="jquery.js"></script> 
<script src="sample.js"></script> 
<script src="book.js"></script> 
</head>
<body onload="sample()">
<p id="table">準備中</p>
<input type="button" value="テスト" onClick="play()" />
</body>
</html>
 
 
function play(){
 
var strx;
 
point=point+1;
 
strx="<h2>"+title[point]+"</h2>";
 
strx=strx+"<br>";
 
strx=strx+"<img src=\""+pic[point]+"\" width=500 height=500>";
 
$("#table").html(strx);
 
}
 
var number;
var title=new Array();
var pic=new Array();
var point;
 
function sample(){
 
point=0;
 
var urlx;
 
 
urlx ="book.php";
 
$.get(urlx, function (csvdata) {
 
    var str = csvdata.split(",");
    var s;
 
number=str.length/2;
 
 
for (s =1; s <number+1;s++ ){
title[s]=str[2*s-2];
pic[s]=str[2*s-1];
}
 
 
$("#table").html(point);
 
});
 
 
}
 
 
<?php
require('calldata.php');
 
$sql="SELECT title,pic FROM book";
 
$result = mysql_query($sql);
 
$sx=0; 
while ($row = mysql_fetch_assoc($result)) {
$sx=$sx+1;
$a[$sx]=$row['title'];
$b[$sx]=$row['pic'];
}
 
$n=$sx;
 
for($s=1;$s<$n;$s++){
print($a[$s]);
print(",");
print($b[$s]);
print(",");
}
$s=$n;
print($a[$s]);
print(",");
print($b[$s]);
 
mysql_close($link);
?>
 
最終更新:2013年12月12日 04:41