我创建了一个数据库来访问使用jquery的滑块内的图像。当我尝试插入连接时,问题就开始了,因为它是一个数组:
<?php
$slides = array(
'<div data-thumb="images/slider/slides/image1_small.jpg" data-src="images/slider/slides/image1.jpg">
<div class="camera_caption fadeFromBottom">
Text 1 below image
</div>
</div>',
'<div data-thumb="images/slider/slides/image2_small.jpg" data-src="images/slider/slides/image2.jpg">
<div class="camera_caption fadeFromBottom">
Text 2 below image
</div>
</div>',
'<div data-thumb="images/slider/slidesimage3_small.jpg" data-src="images/slider/slides/image3.jpg">
<div class="camera_caption fadeFromBottom">
Text 3 below image
</div>
</div>'
);
shuffle($slides);
foreach ($slides as $slides) {
echo "$slides\n";
}
?>
我的问题是,有没有办法更改该数组以访问图像和文本?我尝试了一段时间,但无法弄明白。
更新:我想要的是将数组更改为
<?php
$query = "SELECT * FROM tblslider";
if ($result=mysqli_query($connection, $query)) {
while ($slides = mysqli_fetch_array($result)) {
'<div data-thumb="images/slider/slides/<? echo $row_DataSlider['strImagesmall'] ?>" data-src="images/slider/slides/<? echo $row_DataSlider['strImage'] ?>">
<div class="camera_caption fadeFromBottom">
<? echo $row_DataSlider['strText'] ?>
</div>
</div>'
}
} ?&GT;
显然这是不可能的,但我正在寻找一种解决方案来获得类似的东西
答案 0 :(得分:0)
我相信你的foreach中有一个错字... foreach($幻灯片作为幻灯片)(使用$ slide两次)
我放了:
foreach ($slides as $s) {
echo $s . "</br>";
}