我有使用nivoslider的动态图像和desc滑块框。现在我有很大的问题 - >我的PHP代码是:
<div id="slider" class="nivoSlider">
<?php
$featured = mysql_query("SELECT * FROM featured WHERE order > 0 ORDER BY order ASC");
$count_featured = mysql_num_rows($featured);
if ($count_featured < 1) { echo "error data" }
while ($swcms = mysql_fetch_assoc($featured)) { ?>
<img width="500" height="170" src="<?php echo "$swcms[image]"; ?>" title="#<?PHP echo "$swcms[id]"; ?>" alt="" border="" />
<div id="<?PHP echo "$swcms[id]"; ?>" class="nivo-html-caption"><?PHP echo "$swcms[desc]"; ?> </div>
<?php $c++; }?>
</div>
这工作100%但是在firebug中我看到每张幻灯片后有很多GET未定义的请求:
我发现了问题; nivoslider使用此方法显示图像/ desc(标题):
<div id="slider" class="nivoSlider">
<img src="..." title="#id" />
</div>
<div id="id" class="nivo-html-caption"></div>
我的PHP循环是:
<div id="slider" class="nivoSlider">
<img src="..." title="#id" />
<div id="id" class="nivo-html-caption"></div>
</div>
如何为nivoslider循环修复此PHP代码?
谢谢, 圣诞快乐
答案 0 :(得分:0)
<div id="slider" class="nivoSlider">
<?php
$featured = mysql_query("SELECT * FROM featured WHERE order > 0 ORDER BY order ASC");
$count_featured = mysql_num_rows($featured);
$captions = '';
if ($count_featured < 1) { echo "error data" }
while ($swcms = mysql_fetch_assoc($featured)) { ?>
<img width="500" height="170" src="<?php echo "$swcms[image]"; ?>" title="#<?PHP echo "$swcms[id]"; ?>" alt="" border="" />
<?php $captions .= '<div id="' . $swcms[id] .'" class="nivo-html-caption"' . $swcms[desc] .'</div>'; ?>
<?php $c++; }?>
</div>
<?php echo $captions; ?>