0
我正在创建一个网页,其中包含每个缩略图内的图像(至少3个图像在一个缩略图中)。我正在从数据库中检索这些图像。我的代码如下:如何使用javascript在缩略图内移动多个图像(从phpmyadmin检索)
{foreach $rows as $row}
<img src="{$row.item_picture}"/>
{/foreach}
不过,我想这些图像存储在一个列表中,这样,我可以使图像中的缩略图连续移动这样的:
<html>
<head>
<link rel="stylesheet" type="text/css" href="C://Users//ts00333776//Desktop//theme.css">
<script type="text/javascript">
var rice= new Array() // create new array to preload images
rice[0] = new Image() // create new instance of image object
rice[0].src = "C://Users//ts00333776//Desktop//images//rice1.jpg" // set image src property to image path, preloading image in the process
rice[1] = new Image()
rice[1].src = "C://Users//ts00333776//Desktop//images//rice2.jpg"
rice[2] = new Image()
rice[2].src = "C://Users//ts00333776//Desktop//images//rice3.jpg"
</script>
</head>
<body>
<center>
<table>
<tr>
<td class="first">
<div class="second">
<div class="third">
<img src="C://Users//ts00333776//Desktop//images//rice1.jpg" id="slide" height="250px" width="250px"/>
</div>
<center><h4>some description</h4></center>
</div>
</td>
</tr>
</table>
</center>
<script type="text/javascript">
//variable that will increment through the images
var step=0
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.getElementById('slide').src = rice[step].src
if (step<2)
step++
else
step=0
//call function "slideit()" every 2.5 seconds
setTimeout("slideit()",2500)
}
slideit()
</script>
</body>
</html>`
但是,在上面的代码,我从我的本地,但不是从数据库中检索图像。 任何人都可以帮助我将图像存储在从phpmyadmin中检索的列表中。这样我可以将缩略图内的图像移动。如何移动从数据库中获取的缩略图内的图像? 我的方式是否正确?任何帮助表示赞赏。
这与phpMyAdmin有什么关系? phpMyAdmin是一个管理数据库的工具,而不是数据库本身。也许你的意思是MySQL?你已经尝试了什么?发布特定的错误消息或代码工作不正常可以为您提供更多的帮助,而不是一般性地提出问题。 – 2015-02-09 20:14:27
你对!我正在使用MySQL数据库。我想检索存储在数据库中的图像。我怎样才能做到这一点使用JavaScript? – shet 2015-02-16 15:09:40