-1
好吧,它在這裏! 我正在通過從MySQL數據庫獲取請求獲取圖像數組!並將其顯示爲幻燈片。它的工作!但我現在想要做的是,用Jquery顯示相同的圖像。通過Jquery顯示來自mysql的圖像?
<?php require("Connections/db_con.php"); ?>
<?php
$title = "slideshow";
$id = mysql_real_escape_string((int)$_GET['id']);
$query_pic = "SELECT * FROM photos WHERE listing_id = $id ";
$result_pic = mysql_query($query_pic , $db_con);
$num_pic = mysql_num_rows($result_pic);
$row_pic = mysql_fetch_array($result_pic);
if($num_pic != 0) {
$image_set = array();
$result = mysql_query("SELECT name FROM photos WHERE listing_id= $id");
while($images = mysql_fetch_array($result)) {
array_push($image_set, $images['name']);
}
}
?>
<html>
<head>
<title><>php echo $title; ?></title>
<link rel="stylesheet" href="stylesheets/styles/styles.css" media='all'/>
<link href="stylesheets/layout.css" media="all"/>
<link rel="stylesheet" href="stylesheets/styles/slideshow.css" media='all'/>
<script type='text/javascript'>
var photos = new Array(<?php echo "'".implode("','", $image_set)."'"; ?>);
var start = 0; // array index of first slide
var end = <?php echo $num_pic -1; ?>; // array index of last slide
var current = start;
var doplay = true; // do not play show automatically
// skip to first slide
function first() {
current = 0;
change();
}
// advance to next slide
function previous() {
current -= 1;
if(current < start) current = end; // skip to last slide
change();
}
// go back to previous slide
function next() {
current += 1;
if(current > end) current = start; // skip to first slide
change();
}
// skip to last slide
function last() {
current = end;
change();
}
// change slide according to value of current
function change() {
document.photo.src = 'uploads/' + photos[current];
}
// play automatic slideshow
function play() {
if(doplay == true) {
next();
setTimeout(play, 2000); // call play() in 2.5 seconds
}
}
// pause slideshow
function pause() {
doplay = false;
}
</script>
</head>
<body>
<div id='container'>
<div class='form'>
<div id='photobox'>
<img name='photo' src='uploads/<?php echo $image_set[0]; ?>' alt=''/><br /><br />
<?php // echo "Total " . $num_pic . " photo(s) found" ; ?>
</div>
</div>
</div>
</body>
</html>
我怎麼能與jQuery的幻燈片,而不是一個我現在正在顯示它顯示相同的檢索到的圖像..我盡力,但我不能每次.. :(
哪裏有關於jQuery的一點?我們需要知道該代碼出了什麼問題。 – ariefbayu
有一個用於幻燈片放映的jquery循環插件 – Rafay