我的应用程序将图像上传到文件夹中,并将其路径保存在 mysql 列中。我以以下方式显示这些图像..
$sql = "SELECT * FROM task_table ORDER by RAND()";
//ORDER BY id ASC
$query = mysql_query($sql);
while($row = mysql_fetch_array($query))
{
$file = $row['photo_name'];
$file1 = $row['task_id'];
$task_details=$row['task_details'];
echo '<div id="container">
<div id="thumbnail"><a href="uploads/'. $file .'" title="'.cleanString($file).'" class="thickbox">
<img src="thumbnails/thumb_'.$row['task_id'].'.jpeg" width="282" height="158" alt="image" /></a></div>
<div id="info"><strong>' .cleanString($file).'</strong></br>
<i>' .cleanString($task_details).'</i></div>
</div>';
}
这是带有'thumbnail'作为itemselector的javascript
<script type="text/javascript" src="js/masonry.pkgd.min.js"></script>
<script>
//<![CDATA[$(window).load(function()
{
$(function(){
$('#container').masonry({
itemSelector: '.thumbnail'
});
});
});//]]>
</script>
画廊显示为通常的网格,但与砖石不同。我哪里做错了?如果我的帖子属于错误的类别或者我犯了一些错误,请原谅我,因为这是我在 stackoverflow 中的第一篇帖子 :-)
解决方案
<script>
//<![CDATA[
$(window).load(function(){
$(function(){
$('#container').masonry({
itemSelector: '.thickbox'
});
});
});//]]>
</script>
.....和mysql查询
while($row = mysql_fetch_array($query))
{
$file = $row['photo_name'];
$file1 = $row['task_id'];
$task_details=$row['task_details'];
echo '<div id="container">
<div class="thumbnail"><div class="thickbox">
<img src="uploads/'. $file .'" alt="image"/></div>
<div id="info"><strong>' .cleanString($file).'</strong></br>
<i>' .cleanString($task_details).'</i></div>
</div>';
}